123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- /*******************************************************************************
- ηMatrix - a browser extension to black/white list requests.
- Copyright (C) 2014-2019 Raymond Hill
- Copyright (C) 2019-2022 Alessio Vanni
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see {http://www.gnu.org/licenses/}.
- Home: https://gitlab.com/vannilla/ematrix
- uMatrix Home: https://github.com/gorhill/uMatrix
- */
- 'use strict';
- var ηMatrix = (function () {
- Cu.import('chrome://ematrix/content/lib/LiquidDict.jsm');
- let oneSecond = 1000;
- let oneMinute = 60 * oneSecond;
- let oneHour = 60 * oneMinute;
- let oneDay = 24 * oneHour;
- let _RequestStats = function () {
- this.reset();
- };
- _RequestStats.prototype.reset = function () {
- this.all =
- this.doc =
- this.frame =
- this.script =
- this.css =
- this.image =
- this.media =
- this.xhr =
- this.other =
- this.cookie = 0;
- };
- var RequestStats = function () {
- this.allowed = new _RequestStats ();
- this.blocked = new _RequestStats ();
- };
- RequestStats.prototype.reset = function () {
- this.blocked.reset();
- this.allowed.reset();
- };
- RequestStats.prototype.record = function (type, blocked) {
- // Remember: always test against **false**
- if (blocked !== false) {
- this.blocked[type] += 1;
- this.blocked.all += 1;
- } else {
- this.allowed[type] += 1;
- this.allowed.all += 1;
- }
- };
- var requestStatsFactory = function () {
- return new RequestStats();
- };
- /**
- SVG-based icons below were extracted from
- fontawesome-webfont.svg v4.7. Excerpt of copyright notice at
- the top of the file:
- > Created by FontForge 20120731 at Mon Oct 24 17:37:40 2016
- > By ,,,
- > Copyright Dave Gandy 2016. All rights reserved.
- Excerpt of the license information in the fontawesome CSS
- file bundled with the package:
- > Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome
- > License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
- Font icons:
- - glyph-name: "external_link"
- */
- var rawSettingsDefault = {
- disableCSPReportInjection: false,
- placeholderBackground: [
- 'url("data:image/png;base64,',
- 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAK',
- 'CAAAAACoWZBhAAAABGdBTUEAALGPC/xh',
- 'BQAAAAJiS0dEAP+Hj8y/AAAAB3RJTUUH',
- '3wwIAAgyL/YaPAAAACJJREFUCFtjfMbO',
- 'AAQ/gZiFnQPEBAEmGIMIJgtIL8QEgtoA',
- 'In4D/96X1KAAAAAldEVYdGRhdGU6Y3Jl',
- 'YXRlADIwMTUtMTItMDhUMDA6MDg6NTAr',
- 'MDM6MDAasuuJAAAAJXRFWHRkYXRlOm1v',
- 'ZGlmeQAyMDE1LTEyLTA4VDAwOjA4OjUw',
- 'KzAzOjAwa+9TNQAAAABJRU5ErkJggg==',
- '") ',
- 'repeat scroll #fff'
- ].join(''),
- placeholderBorder: '1px solid rgba(0, 0, 0, 0.1)',
- imagePlaceholder: true,
- imagePlaceholderBackground: 'default',
- imagePlaceholderBorder: 'default',
- framePlaceholder: true,
- framePlaceholderDocument: [
- '<html><head>',
- '<meta charset="utf-8">',
- '<style>',
- 'body { ',
- 'background: {{bg}};',
- 'color: gray;',
- 'font: 12px sans-serif;',
- 'margin: 0;',
- 'overflow: hidden;',
- 'padding: 2px;',
- 'white-space: nowrap;',
- '}',
- 'a { ',
- 'color: inherit;',
- 'padding: 0 3px;',
- 'text-decoration: none;',
- '}',
- 'svg {',
- 'display: inline-block;',
- 'fill: gray;',
- 'height: 12px;',
- 'vertical-align: bottom;',
- 'width: 12px;',
- '}',
- '</style></head><body>',
- '<span><a href="{{url}}" title="{{url}}" target="_blank">',
- '<svg viewBox="0 0 1792 1792"><path transform="scale(1,-1) translate(0,-1536)" d="M1408 608v-320q0 -119 -84.5 -203.5t-203.5 -84.5h-832q-119 0 -203.5 84.5t-84.5 203.5v832q0 119 84.5 203.5t203.5 84.5h704q14 0 23 -9t9 -23v-64q0 -14 -9 -23t-23 -9h-704q-66 0 -113 -47t-47 -113v-832q0 -66 47 -113t113 -47h832q66 0 113 47t47 113v320q0 14 9 23t23 9h64q14 0 23 -9t9 -23zM1792 1472v-512q0 -26 -19 -45t-45 -19t-45 19l-176 176l-652 -652q-10 -10 -23 -10t-23 10l-114 114q-10 10 -10 23t10 23l652 652l-176 176q-19 19 -19 45t19 45t45 19h512q26 0 45 -19t19 -45z" /></svg>',
- '</a>{{url}}</span>',
- '</body></html>'
- ].join(''),
- framePlaceholderBackground: 'default',
- };
- return {
- onBeforeStartQueue: [],
- userSettings: {
- alwaysDetachLogger: false,
- autoUpdate: false,
- clearBrowserCache: true,
- clearBrowserCacheAfter: 60,
- cloudStorageEnabled: false,
- collapseBlacklisted: true,
- collapseBlocked: false,
- colorBlindFriendly: false,
- deleteCookies: false,
- deleteUnusedSessionCookies: false,
- deleteUnusedSessionCookiesAfter: 60,
- deleteLocalStorage: false,
- displayTextSize: '14px',
- externalHostsFiles: '',
- iconBadgeEnabled: false,
- maxLoggedRequests: 1000,
- popupCollapseAllDomains: false,
- popupCollapseBlacklistedDomains: false,
- popupScopeLevel: 'domain',
- processHyperlinkAuditing: true,
- processReferer: false,
- disableUpdateIcon: false,
- resolveCname: false,
- assetsVersion: 1,
- },
- rawSettingsDefault: rawSettingsDefault,
- rawSettings: Object.assign({}, rawSettingsDefault),
- rawSettingsWriteTime: 0,
- clearBrowserCacheCycle: 0,
- cspNoInlineScript: "script-src 'unsafe-eval' blob: *",
- cspNoInlineStyle: "style-src blob: *",
- cspNoWorker: undefined,
- updateAssetsEvery: 11 * oneDay + 1 * oneHour + 1 * oneMinute + 1 * oneSecond,
- firstUpdateAfter: 11 * oneMinute,
- nextUpdateAfter: 11 * oneHour,
- assetsBootstrapLocation: 'assets/assets.json',
- pslAssetKey: 'public_suffix_list.dat',
- // list of live hosts files
- liveHostsFiles: {
- },
- // urls stats are kept on the back burner while waiting to be
- // reactivated in a tab or another.
- pageStores: {},
- pageStoresToken: 0,
- pageStoreCemetery: {},
- // page url => permission scope
- tMatrix: null,
- pMatrix: null,
- ubiquitousBlacklist: new LiquidDict(),
- ubiquitousWhitelist: new LiquidDict(),
- // various stats
- requestStatsFactory: requestStatsFactory,
- requestStats: requestStatsFactory(),
- cookieRemovedCounter: 0,
- localStorageRemovedCounter: 0,
- cookieHeaderFoiledCounter: 0,
- refererHeaderFoiledCounter: 0,
- hyperlinkAuditingFoiledCounter: 0,
- browserCacheClearedCounter: 0,
- storageUsed: 0,
- // record what the browser is doing behind the scene
- behindTheSceneScope: 'behind-the-scene',
- noopFunc: function () {},
- };
- })();
|