diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/assets.js | 6 | ||||
-rw-r--r-- | js/background.js | 2 | ||||
-rw-r--r-- | js/browsercache.js | 16 | ||||
-rw-r--r-- | js/cookies.js | 44 | ||||
-rw-r--r-- | js/httpsb.js | 80 | ||||
-rw-r--r-- | js/liquid-dict.js | 6 | ||||
-rw-r--r-- | js/logger.js | 2 | ||||
-rw-r--r-- | js/matrix.js | 12 | ||||
-rw-r--r-- | js/messaging.js | 266 | ||||
-rw-r--r-- | js/pagestats.js | 22 | ||||
-rw-r--r-- | js/profiler.js | 2 | ||||
-rw-r--r-- | js/start.js | 26 | ||||
-rw-r--r-- | js/storage.js | 98 | ||||
-rw-r--r-- | js/tab.js | 58 | ||||
-rw-r--r-- | js/traffic.js | 108 | ||||
-rw-r--r-- | js/uritools.js | 8 | ||||
-rw-r--r-- | js/usersettings.js | 2 | ||||
-rw-r--r-- | js/utils.js | 12 | ||||
-rw-r--r-- | js/vapi-background.js | 24 | ||||
-rw-r--r-- | js/vapi-client.js | 6 | ||||
-rw-r--r-- | js/vapi-common.js | 4 | ||||
-rw-r--r-- | js/xal.js | 4 |
22 files changed, 404 insertions, 404 deletions
diff --git a/js/assets.js b/js/assets.js index c3fb85f..93a0cf1 100644 --- a/js/assets.js +++ b/js/assets.js @@ -24,7 +24,7 @@ /******************************************************************************/ -µMatrix.assets = (function() { +ηMatrix.assets = (function() { /******************************************************************************/ @@ -101,7 +101,7 @@ api.fetchText = function(url, onLoad, onError) { var onErrorReceived = function() { this.onload = this.onerror = this.ontimeout = null; - µMatrix.logger.writeOne('', 'error', errorCantConnectTo.replace('{{msg}}', actualUrl)); + ηMatrix.logger.writeOne('', 'error', errorCantConnectTo.replace('{{msg}}', actualUrl)); onError.call(null, { url: url, content: '' }); }; @@ -348,7 +348,7 @@ var getAssetSourceRegistry = function(callback) { // First-install case. var createRegistry = function() { api.fetchText( - µMatrix.assetsBootstrapLocation || 'assets/assets.json', + ηMatrix.assetsBootstrapLocation || 'assets/assets.json', function(details) { updateAssetSourceRegistry(details.content, true); registryReady(); diff --git a/js/background.js b/js/background.js index 1a46616..8c8d0ea 100644 --- a/js/background.js +++ b/js/background.js @@ -24,7 +24,7 @@ /******************************************************************************/ -var µMatrix = (function() { // jshint ignore:line +var ηMatrix = (function() { // jshint ignore:line /******************************************************************************/ diff --git a/js/browsercache.js b/js/browsercache.js index 3316a63..5b02a72 100644 --- a/js/browsercache.js +++ b/js/browsercache.js @@ -20,7 +20,7 @@ uMatrix Home: https://github.com/gorhill/uMatrix */ -/* global µMatrix */ +/* global ηMatrix */ /******************************************************************************/ @@ -35,23 +35,23 @@ var clearCache = function() { vAPI.setTimeout(clearCache, 15 * 60 * 1000); - var µm = µMatrix; - if ( !µm.userSettings.clearBrowserCache ) { + var ηm = ηMatrix; + if ( !ηm.userSettings.clearBrowserCache ) { return; } - µm.clearBrowserCacheCycle -= 15; - if ( µm.clearBrowserCacheCycle > 0 ) { + ηm.clearBrowserCacheCycle -= 15; + if ( ηm.clearBrowserCacheCycle > 0 ) { return; } vAPI.browserData.clearCache(); - µm.clearBrowserCacheCycle = µm.userSettings.clearBrowserCacheAfter; - µm.browserCacheClearedCounter++; + ηm.clearBrowserCacheCycle = ηm.userSettings.clearBrowserCacheAfter; + ηm.browserCacheClearedCounter++; // TODO: i18n - µm.logger.writeOne('', 'info', vAPI.i18n('loggerEntryBrowserCacheCleared')); + ηm.logger.writeOne('', 'info', vAPI.i18n('loggerEntryBrowserCacheCleared')); //console.debug('clearBrowserCacheCallback()> vAPI.browserData.clearCache() called'); }; diff --git a/js/cookies.js b/js/cookies.js index 7626ad0..056744f 100644 --- a/js/cookies.js +++ b/js/cookies.js @@ -34,11 +34,11 @@ // Use cached-context approach rather than object-based approach, as details // of the implementation do not need to be visible -µMatrix.cookieHunter = (function() { +ηMatrix.cookieHunter = (function() { /******************************************************************************/ -var µm = µMatrix; +var ηm = ηMatrix; var recordPageCookiesQueue = new Map(); var removePageCookiesQueue = new Map(); @@ -62,7 +62,7 @@ CookieEntry.prototype.init = function(cookie) { this.session = cookie.session; this.anySubdomain = cookie.domain.charAt(0) === '.'; this.hostname = this.anySubdomain ? cookie.domain.slice(1) : cookie.domain; - this.domain = µm.URI.domainFromHostname(this.hostname) || this.hostname; + this.domain = ηm.URI.domainFromHostname(this.hostname) || this.hostname; this.path = cookie.path; this.name = cookie.name; this.value = cookie.value; @@ -146,11 +146,11 @@ var cookieKeyFromCookie = function(cookie) { }; var cookieKeyFromCookieURL = function(url, type, name) { - var µmuri = µm.URI.set(url); + var ηmuri = ηm.URI.set(url); var cb = cookieKeyBuilder; - cb[0] = µmuri.scheme; - cb[2] = µmuri.hostname; - cb[3] = µmuri.path; + cb[0] = ηmuri.scheme; + cb[2] = ηmuri.hostname; + cb[3] = ηmuri.path; cb[5] = type; cb[7] = name; return cb.join(''); @@ -215,7 +215,7 @@ var recordPageCookie = function(pageStore, cookieKey) { var cookieEntry = cookieDict.get(cookieKey); var pageHostname = pageStore.pageHostname; - var block = µm.mustBlock(pageHostname, cookieEntry.hostname, 'cookie'); + var block = ηm.mustBlock(pageHostname, cookieEntry.hostname, 'cookie'); cookieLogEntryBuilder[0] = cookieURLFromCookieEntry(cookieEntry); cookieLogEntryBuilder[2] = cookieEntry.session ? 'session' : 'persistent'; @@ -227,7 +227,7 @@ var recordPageCookie = function(pageStore, cookieKey) { // https://github.com/gorhill/httpswitchboard/issues/60 // Need to URL-encode cookie name pageStore.recordRequest('cookie', cookieURL, block); - µm.logger.writeOne(pageStore.tabId, 'net', pageHostname, cookieURL, 'cookie', block); + ηm.logger.writeOne(pageStore.tabId, 'net', pageHostname, cookieURL, 'cookie', block); cookieEntry.usedOn.add(pageHostname); @@ -238,7 +238,7 @@ var recordPageCookie = function(pageStore, cookieKey) { if ( !block ) { return; } - if ( !µm.userSettings.deleteCookies ) { + if ( !ηm.userSettings.deleteCookies ) { return; } removeCookieAsync(cookieKey); @@ -284,15 +284,15 @@ var chromeCookieRemove = function(cookieEntry, name) { var template = success ? i18nCookieDeleteSuccess : i18nCookieDeleteFailure; if ( removeCookieFromDict(sessionCookieKey) ) { if ( success ) { - µm.cookieRemovedCounter += 1; + ηm.cookieRemovedCounter += 1; } - µm.logger.writeOne('', 'info', 'cookie', template.replace('{{value}}', sessionCookieKey)); + ηm.logger.writeOne('', 'info', 'cookie', template.replace('{{value}}', sessionCookieKey)); } if ( removeCookieFromDict(persistCookieKey) ) { if ( success ) { - µm.cookieRemovedCounter += 1; + ηm.cookieRemovedCounter += 1; } - µm.logger.writeOne('', 'info', 'cookie', template.replace('{{value}}', persistCookieKey)); + ηm.logger.writeOne('', 'info', 'cookie', template.replace('{{value}}', persistCookieKey)); } }; @@ -329,7 +329,7 @@ var processPageRemoveQueue = function() { // Effectively remove cookies. var processRemoveQueue = function() { - var userSettings = µm.userSettings; + var userSettings = ηm.userSettings; var deleteCookies = userSettings.deleteCookies; // Session cookies which timestamp is *after* tstampObsolete will @@ -364,7 +364,7 @@ var processRemoveQueue = function() { // Query scopes only if we are going to use them if ( srcHostnames === undefined ) { - srcHostnames = µm.tMatrix.extractAllSourceHostnames(); + srcHostnames = ηm.tMatrix.extractAllSourceHostnames(); } // Ensure cookie is not allowed on ALL current web pages: It can @@ -389,7 +389,7 @@ var processRemoveQueue = function() { // maybe a user has 1000s of cookies sitting in his browser... var processClean = function() { - var us = µm.userSettings; + var us = ηm.userSettings; if ( us.deleteCookies || us.deleteUnusedSessionCookies ) { var cookieKeys = Array.from(cookieDict.keys()), len = cookieKeys.length, @@ -443,7 +443,7 @@ var canRemoveCookie = function(cookieKey, srcHostnames) { var srcHostname; for ( srcHostname of cookieEntry.usedOn ) { - if ( µm.mustAllow(srcHostname, cookieHostname, 'cookie') ) { + if ( ηm.mustAllow(srcHostname, cookieHostname, 'cookie') ) { return false; } } @@ -455,7 +455,7 @@ var canRemoveCookie = function(cookieKey, srcHostnames) { var pos; for (;;) { if ( srcHostnames.has(srcHostname) ) { - if ( µm.mustAllow(srcHostname, cookieHostname, 'cookie') ) { + if ( ηm.mustAllow(srcHostname, cookieHostname, 'cookie') ) { return false; } } @@ -490,7 +490,7 @@ vAPI.cookies.onChanged = function(cookie) { // Go through all pages and update if needed, as one cookie can be used // by many web pages, so they need to be recorded for all these pages. - var pageStores = µm.pageStores; + var pageStores = ηm.pageStores; var pageStore; for ( var tabId in pageStores ) { if ( pageStores.hasOwnProperty(tabId) === false ) { @@ -511,7 +511,7 @@ vAPI.cookies.onChanged = function(cookie) { vAPI.cookies.onRemoved = function(cookie) { var cookieKey = cookieKeyFromCookie(cookie); if ( removeCookieFromDict(cookieKey) ) { - µm.logger.writeOne('', 'info', 'cookie', i18nCookieDeleteSuccess.replace('{{value}}', cookieKey)); + ηm.logger.writeOne('', 'info', 'cookie', i18nCookieDeleteSuccess.replace('{{value}}', cookieKey)); } }; @@ -522,7 +522,7 @@ vAPI.cookies.onRemoved = function(cookie) { vAPI.cookies.onAllRemoved = function() { for ( var cookieKey of cookieDict.keys() ) { if ( removeCookieFromDict(cookieKey) ) { - µm.logger.writeOne('', 'info', 'cookie', i18nCookieDeleteSuccess.replace('{{value}}', cookieKey)); + ηm.logger.writeOne('', 'info', 'cookie', i18nCookieDeleteSuccess.replace('{{value}}', cookieKey)); } } }; diff --git a/js/httpsb.js b/js/httpsb.js index d76371a..331aa23 100644 --- a/js/httpsb.js +++ b/js/httpsb.js @@ -20,52 +20,52 @@ uMatrix Home: https://github.com/gorhill/uMatrix */ -/* global chrome, µMatrix */ +/* global chrome, ηMatrix */ 'use strict'; /******************************************************************************/ (function() { - var µm = µMatrix; - µm.pMatrix = new µm.Matrix(); - µm.pMatrix.setSwitch('matrix-off', 'about-scheme', 1); - µm.pMatrix.setSwitch('matrix-off', 'chrome-extension-scheme', 1); - µm.pMatrix.setSwitch('matrix-off', 'chrome-scheme', 1); - µm.pMatrix.setSwitch('matrix-off', 'moz-extension-scheme', 1); - µm.pMatrix.setSwitch('matrix-off', 'opera-scheme', 1); + var ηm = ηMatrix; + ηm.pMatrix = new ηm.Matrix(); + ηm.pMatrix.setSwitch('matrix-off', 'about-scheme', 1); + ηm.pMatrix.setSwitch('matrix-off', 'chrome-extension-scheme', 1); + ηm.pMatrix.setSwitch('matrix-off', 'chrome-scheme', 1); + ηm.pMatrix.setSwitch('matrix-off', 'moz-extension-scheme', 1); + ηm.pMatrix.setSwitch('matrix-off', 'opera-scheme', 1); // https://discourse.mozilla.org/t/support-umatrix/5131/157 - µm.pMatrix.setSwitch('matrix-off', 'wyciwyg-scheme', 1); - µm.pMatrix.setSwitch('matrix-off', 'behind-the-scene', 1); - µm.pMatrix.setSwitch('referrer-spoof', 'behind-the-scene', 2); - µm.pMatrix.setSwitch('https-strict', 'behind-the-scene', 2); + ηm.pMatrix.setSwitch('matrix-off', 'wyciwyg-scheme', 1); + ηm.pMatrix.setSwitch('matrix-off', 'behind-the-scene', 1); + ηm.pMatrix.setSwitch('referrer-spoof', 'behind-the-scene', 2); + ηm.pMatrix.setSwitch('https-strict', 'behind-the-scene', 2); // Global rules - µm.pMatrix.setSwitch('referrer-spoof', '*', 1); - µm.pMatrix.setSwitch('noscript-spoof', '*', 1); - µm.pMatrix.setCell('*', '*', '*', µm.Matrix.Red); - µm.pMatrix.setCell('*', '*', 'css', µm.Matrix.Green); - µm.pMatrix.setCell('*', '*', 'image', µm.Matrix.Green); - µm.pMatrix.setCell('*', '*', 'frame', µm.Matrix.Red); + ηm.pMatrix.setSwitch('referrer-spoof', '*', 1); + ηm.pMatrix.setSwitch('noscript-spoof', '*', 1); + ηm.pMatrix.setCell('*', '*', '*', ηm.Matrix.Red); + ηm.pMatrix.setCell('*', '*', 'css', ηm.Matrix.Green); + ηm.pMatrix.setCell('*', '*', 'image', ηm.Matrix.Green); + ηm.pMatrix.setCell('*', '*', 'frame', ηm.Matrix.Red); // 1st-party rules - µm.pMatrix.setCell('*', '1st-party', '*', µm.Matrix.Green); - µm.pMatrix.setCell('*', '1st-party', 'frame', µm.Matrix.Green); + ηm.pMatrix.setCell('*', '1st-party', '*', ηm.Matrix.Green); + ηm.pMatrix.setCell('*', '1st-party', 'frame', ηm.Matrix.Green); - µm.tMatrix = new µm.Matrix(); - µm.tMatrix.assign(µm.pMatrix); + ηm.tMatrix = new ηm.Matrix(); + ηm.tMatrix.assign(ηm.pMatrix); })(); /******************************************************************************/ -µMatrix.hostnameFromURL = function(url) { +ηMatrix.hostnameFromURL = function(url) { var hn = this.URI.hostnameFromURI(url); return hn === '' ? '*' : hn; }; -µMatrix.scopeFromURL = µMatrix.hostnameFromURL; +ηMatrix.scopeFromURL = ηMatrix.hostnameFromURL; /******************************************************************************/ -µMatrix.evaluateURL = function(srcURL, desHostname, type) { +ηMatrix.evaluateURL = function(srcURL, desHostname, type) { var srcHostname = this.URI.hostnameFromURI(srcURL); return this.tMatrix.evaluateCellZXY(srcHostname, desHostname, type); }; @@ -75,11 +75,11 @@ // Whitelist something -µMatrix.whitelistTemporarily = function(srcHostname, desHostname, type) { +ηMatrix.whitelistTemporarily = function(srcHostname, desHostname, type) { this.tMatrix.whitelistCell(srcHostname, desHostname, type); }; -µMatrix.whitelistPermanently = function(srcHostname, desHostname, type) { +ηMatrix.whitelistPermanently = function(srcHostname, desHostname, type) { if ( this.pMatrix.whitelistCell(srcHostname, desHostname, type) ) { this.saveMatrix(); } @@ -90,7 +90,7 @@ // Auto-whitelisting the `all` cell is a serious action, hence this will be // done only from within a scope. -µMatrix.autoWhitelistAllTemporarily = function(pageURL) { +ηMatrix.autoWhitelistAllTemporarily = function(pageURL) { var srcHostname = this.URI.hostnameFromURI(pageURL); if ( this.mustBlock(srcHostname, '*', '*') === false ) { return false; @@ -103,11 +103,11 @@ // Blacklist something -µMatrix.blacklistTemporarily = function(srcHostname, desHostname, type) { +ηMatrix.blacklistTemporarily = function(srcHostname, desHostname, type) { this.tMatrix.blacklistCell(srcHostname, desHostname, type); }; -µMatrix.blacklistPermanently = function(srcHostname, desHostname, type) { +ηMatrix.blacklistPermanently = function(srcHostname, desHostname, type) { if ( this.pMatrix.blacklist(srcHostname, desHostname, type) ) { this.saveMatrix(); } @@ -117,11 +117,11 @@ // Remove something from both black and white lists. -µMatrix.graylistTemporarily = function(srcHostname, desHostname, type) { +ηMatrix.graylistTemporarily = function(srcHostname, desHostname, type) { this.tMatrix.graylistCell(srcHostname, desHostname, type); }; -µMatrix.graylistPermanently = function(srcHostname, desHostname, type) { +ηMatrix.graylistPermanently = function(srcHostname, desHostname, type) { if ( this.pMatrix.graylistCell(srcHostname, desHostname, type) ) { this.saveMatrix(); } @@ -133,7 +133,7 @@ // issue at this point but to keep in mind as this function is called // more and more from different places. -µMatrix.filterRequest = function(fromURL, type, toURL) { +ηMatrix.filterRequest = function(fromURL, type, toURL) { // Block request? var srcHostname = this.hostnameFromURL(fromURL); var desHostname = this.hostnameFromURL(toURL); @@ -150,11 +150,11 @@ /******************************************************************************/ -µMatrix.mustBlock = function(srcHostname, desHostname, type) { +ηMatrix.mustBlock = function(srcHostname, desHostname, type) { return this.tMatrix.mustBlock(srcHostname, desHostname, type); }; -µMatrix.mustAllow = function(srcHostname, desHostname, type) { +ηMatrix.mustAllow = function(srcHostname, desHostname, type) { return this.mustBlock(srcHostname, desHostname, type) === false; }; @@ -162,7 +162,7 @@ // Commit temporary permissions. -µMatrix.commitPermissions = function(persist) { +ηMatrix.commitPermissions = function(persist) { this.pMatrix.assign(this.tMatrix); if ( persist ) { this.saveMatrix(); @@ -173,23 +173,23 @@ // Reset all rules to their default state. -µMatrix.revertAllRules = function() { +ηMatrix.revertAllRules = function() { this.tMatrix.assign(this.pMatrix); }; /******************************************************************************/ -µMatrix.turnOff = function() { +ηMatrix.turnOff = function() { vAPI.app.start(); }; -µMatrix.turnOn = function() { +ηMatrix.turnOn = function() { vAPI.app.stop(); }; /******************************************************************************/ -µMatrix.formatCount = function(count) { +ηMatrix.formatCount = function(count) { if ( typeof count !== 'number' ) { return ''; } diff --git a/js/liquid-dict.js b/js/liquid-dict.js index 92ca58c..3f3da08 100644 --- a/js/liquid-dict.js +++ b/js/liquid-dict.js @@ -22,7 +22,7 @@ /******************************************************************************/ -µMatrix.LiquidDict = (function() { +ηMatrix.LiquidDict = (function() { /******************************************************************************/ @@ -199,5 +199,5 @@ return LiquidDict; /******************************************************************************/ -µMatrix.ubiquitousBlacklist = new µMatrix.LiquidDict(); -µMatrix.ubiquitousWhitelist = new µMatrix.LiquidDict(); +ηMatrix.ubiquitousBlacklist = new ηMatrix.LiquidDict(); +ηMatrix.ubiquitousWhitelist = new ηMatrix.LiquidDict(); diff --git a/js/logger.js b/js/logger.js index 896fbdf..7fe56dc 100644 --- a/js/logger.js +++ b/js/logger.js @@ -25,7 +25,7 @@ /******************************************************************************/ /******************************************************************************/ -µMatrix.logger = (function() { +ηMatrix.logger = (function() { var LogEntry = function(args) { this.init(args); diff --git a/js/matrix.js b/js/matrix.js index 59eb84a..d1abcfc 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -27,11 +27,11 @@ /******************************************************************************/ -µMatrix.Matrix = (function() { +ηMatrix.Matrix = (function() { /******************************************************************************/ -var µm = µMatrix; +var ηm = ηMatrix; var magicId = 'axyorpwxtmnf'; var uniqueIdGenerator = 1; @@ -178,9 +178,9 @@ var extractFirstPartyDesDomain = function(srcHostname, desHostname) { if ( srcHostname === '*' || desHostname === '*' || desHostname === '1st-party' ) { return ''; } - var µmuri = µm.URI; - var srcDomain = µmuri.domainFromHostname(srcHostname) || srcHostname; - var desDomain = µmuri.domainFromHostname(desHostname) || desHostname; + var ηmuri = ηm.URI; + var srcDomain = ηmuri.domainFromHostname(srcHostname) || srcHostname; + var desDomain = ηmuri.domainFromHostname(desHostname) || desHostname; return desDomain === srcDomain ? desDomain : ''; }; @@ -366,7 +366,7 @@ Matrix.prototype.evaluateCellZ = function(srcHostname, desHostname, type) { // srcHostname is '*' at this point // Preset blacklisted hostnames are blacklisted in global scope - if ( type === '*' && µm.ubiquitousBlacklist.test(desHostname) ) { + if ( type === '*' && ηm.ubiquitousBlacklist.test(desHostname) ) { return 1; } diff --git a/js/messaging.js b/js/messaging.js index d5c472f..0a1ff4a 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -29,7 +29,7 @@ (function() { -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ @@ -39,11 +39,11 @@ function onMessage(request, sender, callback) { // Async switch ( request.what ) { case 'getAssetContent': - µm.assets.get(request.url, { dontCache: true }, callback); + ηm.assets.get(request.url, { dontCache: true }, callback); return; case 'selectHostsFiles': - µm.selectHostsFiles(request, callback); + ηm.selectHostsFiles(request, callback); return; default: @@ -55,35 +55,35 @@ function onMessage(request, sender, callback) { switch ( request.what ) { case 'forceReloadTab': - µm.forceReload(request.tabId, request.bypassCache); + ηm.forceReload(request.tabId, request.bypassCache); break; case 'forceUpdateAssets': - µm.scheduleAssetUpdater(0); - µm.assets.updateStart({ delay: 2000 }); + ηm.scheduleAssetUpdater(0); + ηm.assets.updateStart({ delay: 2000 }); break; case 'getUserSettings': response = { - userSettings: µm.userSettings, + userSettings: ηm.userSettings, matrixSwitches: { - 'https-strict': µm.pMatrix.evaluateSwitch('https-strict', '*') === 1, - 'referrer-spoof': µm.pMatrix.evaluateSwitch('referrer-spoof', '*') === 1, - 'noscript-spoof': µm.pMatrix.evaluateSwitch('noscript-spoof', '*') === 1 + 'https-strict': ηm.pMatrix.evaluateSwitch('https-strict', '*') === 1, + 'referrer-spoof': ηm.pMatrix.evaluateSwitch('referrer-spoof', '*') === 1, + 'noscript-spoof': ηm.pMatrix.evaluateSwitch('noscript-spoof', '*') === 1 } }; break; case 'gotoExtensionURL': - µm.gotoExtensionURL(request); + ηm.gotoExtensionURL(request); break; case 'gotoURL': - µm.gotoURL(request); + ηm.gotoURL(request); break; case 'mustBlock': - response = µm.mustBlock( + response = ηm.mustBlock( request.scope, request.hostname, request.type @@ -91,17 +91,17 @@ function onMessage(request, sender, callback) { break; case 'readRawSettings': - response = µm.stringFromRawSettings(); + response = ηm.stringFromRawSettings(); break; case 'reloadHostsFiles': - µm.reloadHostsFiles(); + ηm.reloadHostsFiles(); break; case 'setMatrixSwitch': - µm.tMatrix.setSwitch(request.switchName, '*', request.state); - if ( µm.pMatrix.setSwitch(request.switchName, '*', request.state) ) { - µm.saveMatrix(); + ηm.tMatrix.setSwitch(request.switchName, '*', request.state); + if ( ηm.pMatrix.setSwitch(request.switchName, '*', request.state) ) { + ηm.saveMatrix(); } break; @@ -109,11 +109,11 @@ function onMessage(request, sender, callback) { if ( request.hasOwnProperty('value') === false ) { request.value = undefined; } - response = µm.changeUserSettings(request.name, request.value); + response = ηm.changeUserSettings(request.name, request.value); break; case 'writeRawSettings': - µm.rawSettingsFromString(request.content); + ηm.rawSettingsFromString(request.content); break; default: @@ -138,7 +138,7 @@ vAPI.messaging.setup(onMessage); // popup.js -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ @@ -146,15 +146,15 @@ var µm = µMatrix; var RowSnapshot = function(srcHostname, desHostname, desDomain) { this.domain = desDomain; - this.temporary = µm.tMatrix.evaluateRowZXY(srcHostname, desHostname); - this.permanent = µm.pMatrix.evaluateRowZXY(srcHostname, desHostname); + this.temporary = ηm.tMatrix.evaluateRowZXY(srcHostname, desHostname); + this.permanent = ηm.pMatrix.evaluateRowZXY(srcHostname, desHostname); this.counts = RowSnapshot.counts.slice(); this.totals = RowSnapshot.counts.slice(); }; RowSnapshot.counts = (function() { var aa = []; - for ( var i = 0, n = µm.Matrix.columnHeaderIndices.size; i < n; i++ ) { + for ( var i = 0, n = ηm.Matrix.columnHeaderIndices.size; i < n; i++ ) { aa[i] = 0; } return aa; @@ -163,14 +163,14 @@ RowSnapshot.counts = (function() { /******************************************************************************/ var matrixSnapshot = function(pageStore, details) { - var µmuser = µm.userSettings; - var headerIndices = µm.Matrix.columnHeaderIndices; + var ηmuser = ηm.userSettings; + var headerIndices = ηm.Matrix.columnHeaderIndices; var r = { appVersion: vAPI.app.version, blockedCount: pageStore.requestStats.blocked.all, - collapseAllDomains: µmuser.popupCollapseAllDomains, - collapseBlacklistedDomains: µmuser.popupCollapseBlacklistedDomains, + collapseAllDomains: ηmuser.popupCollapseAllDomains, + collapseBlacklistedDomains: ηmuser.popupCollapseBlacklistedDomains, diff: [], domain: pageStore.pageDomain, has3pReferrer: pageStore.has3pReferrer, @@ -183,35 +183,35 @@ var matrixSnapshot = function(pageStore, details) { mtxCountModified: pageStore.mtxCountModifiedTime !== details.mtxCountModifiedTime, mtxContentModifiedTime: pageStore.mtxContentModifiedTime, mtxCountModifiedTime: pageStore.mtxCountModifiedTime, - pMatrixModified: µm.pMatrix.modifiedTime !== details.pMatrixModifiedTime, - pMatrixModifiedTime: µm.pMatrix.modifiedTime, + pMatrixModified: ηm.pMatrix.modifiedTime !== details.pMatrixModifiedTime, + pMatrixModifiedTime: ηm.pMatrix.modifiedTime, pSwitches: {}, rows: {}, rowCount: 0, scope: '*', tabId: pageStore.tabId, - tMatrixModified: µm.tMatrix.modifiedTime !== details.tMatrixModifiedTime, - tMatrixModifiedTime: µm.tMatrix.modifiedTime, + tMatrixModified: ηm.tMatrix.modifiedTime !== details.tMatrixModifiedTime, + tMatrixModifiedTime: ηm.tMatrix.modifiedTime, tSwitches: {}, url: pageStore.pageUrl, userSettings: { - colorBlindFriendly: µmuser.colorBlindFriendly, - displayTextSize: µmuser.displayTextSize, - popupScopeLevel: µmuser.popupScopeLevel + colorBlindFriendly: ηmuser.colorBlindFriendly, + displayTextSize: ηmuser.displayTextSize, + popupScopeLevel: ηmuser.popupScopeLevel } }; if ( typeof details.scope === 'string' ) { r.scope = details.scope; - } else if ( µmuser.popupScopeLevel === 'site' ) { + } else if ( ηmuser.popupScopeLevel === 'site' ) { r.scope = r.hostname; - } else if ( µmuser.popupScopeLevel === 'domain' ) { + } else if ( ηmuser.popupScopeLevel === 'domain' ) { r.scope = r.domain; } - for ( var switchName of µm.Matrix.switchNames ) { - r.tSwitches[switchName] = µm.tMatrix.evaluateSwitchZ(switchName, r.scope); - r.pSwitches[switchName] = µm.pMatrix.evaluateSwitchZ(switchName, r.scope); + for ( var switchName of ηm.Matrix.switchNames ) { + r.tSwitches[switchName] = ηm.tMatrix.evaluateSwitchZ(switchName, r.scope); + r.pSwitches[switchName] = ηm.pMatrix.evaluateSwitchZ(switchName, r.scope); } // These rows always exist @@ -219,7 +219,7 @@ var matrixSnapshot = function(pageStore, details) { r.rows['1st-party'] = new RowSnapshot(r.scope, '1st-party', '1st-party'); r.rowCount += 1; - var µmuri = µm.URI; + var ηmuri = ηm.URI; var reqType, reqHostname, reqDomain; var desHostname; var row, typeIndex; @@ -235,7 +235,7 @@ var matrixSnapshot = function(pageStore, details) { if ( reqHostname === '' ) { reqHostname = pageStore.pageHostname; } - reqDomain = µmuri.domainFromHostname(reqHostname) || reqHostname; + reqDomain = ηmuri.domainFromHostname(reqHostname) || reqHostname; // We want rows of self and ancestors desHostname = reqHostname; @@ -263,7 +263,7 @@ var matrixSnapshot = function(pageStore, details) { row.totals[anyIndex] += count; } - r.diff = µm.tMatrix.diff(µm.pMatrix, r.hostname, Object.keys(r.rows)); + r.diff = ηm.tMatrix.diff(ηm.pMatrix, r.hostname, Object.keys(r.rows)); return r; }; @@ -272,7 +272,7 @@ var matrixSnapshot = function(pageStore, details) { var matrixSnapshotFromTabId = function(details, callback) { var matrixSnapshotIf = function(tabId, details) { - var pageStore = µm.pageStoreFromTabId(tabId); + var pageStore = ηm.pageStoreFromTabId(tabId); if ( pageStore === null ) { callback('ENOTFOUND'); return; @@ -280,8 +280,8 @@ var matrixSnapshotFromTabId = function(details, callback) { // First verify whether we must return data or not. if ( - µm.tMatrix.modifiedTime === details.tMatrixModifiedTime && - µm.pMatrix.modifiedTime === details.pMatrixModifiedTime && + ηm.tMatrix.modifiedTime === details.tMatrixModifiedTime && + ηm.pMatrix.modifiedTime === details.pMatrixModifiedTime && pageStore.mtxContentModifiedTime === details.mtxContentModifiedTime && pageStore.mtxCountModifiedTime === details.mtxCountModifiedTime ) { @@ -333,15 +333,15 @@ var onMessage = function(request, sender, callback) { switch ( request.what ) { case 'toggleMatrixSwitch': - µm.tMatrix.setSwitchZ( + ηm.tMatrix.setSwitchZ( request.switchName, request.srcHostname, - µm.tMatrix.evaluateSwitchZ(request.switchName, request.srcHostname) === false + ηm.tMatrix.evaluateSwitchZ(request.switchName, request.srcHostname) === false ); break; case 'blacklistMatrixCell': - µm.tMatrix.blacklistCell( + ηm.tMatrix.blacklistCell( request.srcHostname, request.desHostname, request.type @@ -349,7 +349,7 @@ var onMessage = function(request, sender, callback) { break; case 'whitelistMatrixCell': - µm.tMatrix.whitelistCell( + ηm.tMatrix.whitelistCell( request.srcHostname, request.desHostname, request.type @@ -357,7 +357,7 @@ var onMessage = function(request, sender, callback) { break; case 'graylistMatrixCell': - µm.tMatrix.graylistCell( + ηm.tMatrix.graylistCell( request.srcHostname, request.desHostname, request.type @@ -365,17 +365,17 @@ var onMessage = function(request, sender, callback) { break; case 'applyDiffToPermanentMatrix': // aka "persist" - if ( µm.pMatrix.applyDiff(request.diff, µm.tMatrix) ) { - µm.saveMatrix(); + if ( ηm.pMatrix.applyDiff(request.diff, ηm.tMatrix) ) { + ηm.saveMatrix(); } break; case 'applyDiffToTemporaryMatrix': // aka "revert" - µm.tMatrix.applyDiff(request.diff, µm.pMatrix); + ηm.tMatrix.applyDiff(request.diff, ηm.pMatrix); break; case 'revertTemporaryMatrix': - µm.tMatrix.assign(µm.pMatrix); + ηm.tMatrix.assign(ηm.pMatrix); break; default: @@ -396,7 +396,7 @@ vAPI.messaging.listen('popup.js', onMessage); (function() { -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ @@ -404,12 +404,12 @@ var foundInlineCode = function(tabId, pageStore, details, type) { if ( pageStore === null ) { return; } var pageHostname = pageStore.pageHostname, - µmuri = µm.URI.set(details.documentURI), - frameURL = µmuri.normalizedURI(); + ηmuri = ηm.URI.set(details.documentURI), + frameURL = ηmuri.normalizedURI(); var blocked = details.blocked; if ( blocked === undefined ) { - blocked = µm.mustBlock(pageHostname, µmuri.hostname, type); + blocked = ηm.mustBlock(pageHostname, ηmuri.hostname, type); } var mapTo = { @@ -421,31 +421,31 @@ var foundInlineCode = function(tabId, pageStore, details, type) { // Look-up here whether inline scripting is blocked for the frame. var url = frameURL + '{inline_' + mapTo[type] + '}'; pageStore.recordRequest(type, url, blocked); - µm.logger.writeOne(tabId, 'net', pageHostname, url, type, blocked); + ηm.logger.writeOne(tabId, 'net', pageHostname, url, type, blocked); }; /******************************************************************************/ var contentScriptLocalStorageHandler = function(tabId, originURL) { - var tabContext = µm.tabContextManager.lookup(tabId); + var tabContext = ηm.tabContextManager.lookup(tabId); if ( tabContext === null ) { return; } - var blocked = µm.mustBlock( + var blocked = ηm.mustBlock( tabContext.rootHostname, - µm.URI.hostnameFromURI(originURL), + ηm.URI.hostnameFromURI(originURL), 'cookie' ); - var pageStore = µm.pageStoreFromTabId(tabId); + var pageStore = ηm.pageStoreFromTabId(tabId); if ( pageStore !== null ) { var requestURL = originURL + '/{localStorage}'; pageStore.recordRequest('cookie', requestURL, blocked); - µm.logger.writeOne(tabId, 'net', tabContext.rootHostname, requestURL, 'cookie', blocked); + ηm.logger.writeOne(tabId, 'net', tabContext.rootHostname, requestURL, 'cookie', blocked); } - var removeStorage = blocked && µm.userSettings.deleteLocalStorage; + var removeStorage = blocked && ηm.userSettings.deleteLocalStorage; if ( removeStorage ) { - µm.localStorageRemovedCounter++; + ηm.localStorageRemovedCounter++; } return removeStorage; @@ -456,33 +456,33 @@ var contentScriptLocalStorageHandler = function(tabId, originURL) { // Evaluate many URLs against the matrix. var lookupBlockedCollapsibles = function(tabId, requests) { - if ( placeholdersReadTime < µm.rawSettingsWriteTime ) { + if ( placeholdersReadTime < ηm.rawSettingsWriteTime ) { placeholders = undefined; } if ( placeholders === undefined ) { placeholders = { - frame: µm.rawSettings.framePlaceholder, - image: µm.rawSettings.imagePlaceholder + frame: ηm.rawSettings.framePlaceholder, + image: ηm.rawSettings.imagePlaceholder }; if ( placeholders.frame ) { placeholders.frameDocument = - µm.rawSettings.framePlaceholderDocument.replace( + ηm.rawSettings.framePlaceholderDocument.replace( '{{bg}}', - µm.rawSettings.framePlaceholderBackground !== 'default' ? - µm.rawSettings.framePlaceholderBackground : - µm.rawSettings.placeholderBackground + ηm.rawSettings.framePlaceholderBackground !== 'default' ? + ηm.rawSettings.framePlaceholderBackground : + ηm.rawSettings.placeholderBackground ); } if ( placeholders.image ) { placeholders.imageBorder = - µm.rawSettings.imagePlaceholderBorder !== 'default' ? - µm.rawSettings.imagePlaceholderBorder : - µm.rawSettings.placeholderBorder; + ηm.rawSettings.imagePlaceholderBorder !== 'default' ? + ηm.rawSettings.imagePlaceholderBorder : + ηm.rawSettings.placeholderBorder; placeholders.imageBackground = - µm.rawSettings.imagePlaceholderBackground !== 'default' ? - µm.rawSettings.imagePlaceholderBackground : - µm.rawSettings.placeholderBackground; + ηm.rawSettings.imagePlaceholderBackground !== 'default' ? + ηm.rawSettings.imagePlaceholderBackground : + ηm.rawSettings.placeholderBackground; } placeholdersReadTime = Date.now(); } @@ -494,12 +494,12 @@ var lookupBlockedCollapsibles = function(tabId, requests) { placeholders: placeholders }; - var tabContext = µm.tabContextManager.lookup(tabId); + var tabContext = ηm.tabContextManager.lookup(tabId); if ( tabContext === null ) { return response; } - var pageStore = µm.pageStoreFromTabId(tabId); + var pageStore = ηm.pageStoreFromTabId(tabId); if ( pageStore !== null ) { pageStore.lookupBlockedCollapsibles(requests, response); } @@ -520,9 +520,9 @@ var onMessage = function(request, sender, callback) { } var tabId = sender && sender.tab ? sender.tab.id || 0 : 0, - tabContext = µm.tabContextManager.lookup(tabId), + tabContext = ηm.tabContextManager.lookup(tabId), rootHostname = tabContext && tabContext.rootHostname, - pageStore = µm.pageStoreFromTabId(tabId); + pageStore = ηm.pageStoreFromTabId(tabId); // Sync var response; @@ -539,20 +539,20 @@ var onMessage = function(request, sender, callback) { case 'mustRenderNoscriptTags?': if ( tabContext === null ) { break; } response = - µm.tMatrix.mustBlock(rootHostname, rootHostname, 'script') && - µm.tMatrix.evaluateSwitchZ('noscript-spoof', rootHostname); + ηm.tMatrix.mustBlock(rootHostname, rootHostname, 'script') && + ηm.tMatrix.evaluateSwitchZ('noscript-spoof', rootHostname); if ( pageStore !== null ) { pageStore.hasNoscriptTags = true; } // https://github.com/gorhill/uMatrix/issues/225 // A good place to force an update of the page title, as at // this point the DOM has been loaded. - µm.updateTitle(tabId); + ηm.updateTitle(tabId); break; case 'securityPolicyViolation': if ( request.directive === 'worker-src' ) { - var url = µm.URI.hostnameFromURI(request.blockedURI) !== '' ? + var url = ηm.URI.hostnameFromURI(request.blockedURI) !== '' ? request.blockedURI : request.documentURI; if ( pageStore !== null ) { @@ -560,7 +560,7 @@ var onMessage = function(request, sender, callback) { pageStore.recordRequest('script', url, true); } if ( tabContext !== null ) { - µm.logger.writeOne(tabId, 'net', rootHostname, url, 'worker', request.blocked); + ηm.logger.writeOne(tabId, 'net', rootHostname, url, 'worker', request.blocked); } } else if ( request.directive === 'script-src' ) { foundInlineCode(tabId, pageStore, request, 'script'); @@ -571,7 +571,7 @@ var onMessage = function(request, sender, callback) { case 'shutdown?': if ( tabContext !== null ) { - response = µm.tMatrix.evaluateSwitchZ('matrix-off', rootHostname); + response = ηm.tMatrix.evaluateSwitchZ('matrix-off', rootHostname); } break; @@ -597,7 +597,7 @@ vAPI.messaging.listen('contentscript.js', onMessage); /******************************************************************************/ -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ @@ -606,7 +606,7 @@ var onMessage = function(request, sender, callback) { switch ( request.what ) { case 'cloudGetOptions': vAPI.cloud.getOptions(function(options) { - options.enabled = µm.userSettings.cloudStorageEnabled === true; + options.enabled = ηm.userSettings.cloudStorageEnabled === true; callback(options); }); return; @@ -655,7 +655,7 @@ vAPI.messaging.listen('cloud-ui.js', onMessage); (function() { -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ @@ -673,22 +673,22 @@ var onMessage = function(request, sender, callback) { switch ( request.what ) { case 'getUserRules': response = { - temporaryRules: µm.tMatrix.toString(), - permanentRules: µm.pMatrix.toString() + temporaryRules: ηm.tMatrix.toString(), + permanentRules: ηm.pMatrix.toString() }; break; case 'setUserRules': if ( typeof request.temporaryRules === 'string' ) { - µm.tMatrix.fromString(request.temporaryRules); + ηm.tMatrix.fromString(request.temporaryRules); } if ( typeof request.permanentRules === 'string' ) { - µm.pMatrix.fromString(request.permanentRules); - µm.saveMatrix(); + ηm.pMatrix.fromString(request.permanentRules); + ηm.saveMatrix(); } response = { - temporaryRules: µm.tMatrix.toString(), - permanentRules: µm.pMatrix.toString() + temporaryRules: ηm.tMatrix.toString(), + permanentRules: ηm.pMatrix.toString() }; break; @@ -710,12 +710,12 @@ vAPI.messaging.listen('user-rules.js', onMessage); (function() { -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ var prepEntries = function(entries) { - var µmuri = µm.URI; + var ηmuri = ηm.URI; var entry; for ( var k in entries ) { if ( entries.hasOwnProperty(k) === false ) { @@ -723,8 +723,8 @@ var prepEntries = function(entries) { } entry = entries[k]; if ( typeof entry.homeURL === 'string' ) { - entry.homeHostname = µmuri.hostnameFromURI(entry.homeURL); - entry.homeDomain = µmuri.domainFromHostname(entry.homeHostname); + entry.homeHostname = ηmuri.hostnameFromURI(entry.homeURL); + entry.homeDomain = ηmuri.domainFromHostname(entry.homeHostname); } } }; @@ -733,11 +733,11 @@ var prepEntries = function(entries) { var getLists = function(callback) { var r = { - autoUpdate: µm.userSettings.autoUpdate, + autoUpdate: ηm.userSettings.autoUpdate, available: null, cache: null, - current: µm.liveHostsFiles, - blockedHostnameCount: µm.ubiquitousBlacklist.count + current: ηm.liveHostsFiles, + blockedHostnameCount: ηm.ubiquitousBlacklist.count }; var onMetadataReady = function(entries) { r.cache = entries; @@ -747,15 +747,15 @@ var getLists = function(callback) { var onAvailableHostsFilesReady = function(lists) { r.available = lists; prepEntries(r.available); - µm.assets.metadata(onMetadataReady); + ηm.assets.metadata(onMetadataReady); }; - µm.getAvailableHostsFiles(onAvailableHostsFilesReady); + ηm.getAvailableHostsFiles(onAvailableHostsFilesReady); }; /******************************************************************************/ var onMessage = function(request, sender, callback) { - var µm = µMatrix; + var ηm = ηMatrix; // Async switch ( request.what ) { @@ -771,15 +771,15 @@ var onMessage = function(request, sender, callback) { switch ( request.what ) { case 'purgeCache': - µm.assets.purge(request.assetKey); - µm.assets.remove('compiled/' + request.assetKey); + ηm.assets.purge(request.assetKey); + ηm.assets.remove('compiled/' + request.assetKey); break; case 'purgeAllCaches': if ( request.hard ) { - µm.assets.remove(/./); + ηm.assets.remove(/./); } else { - µm.assets.purge(/./, 'public_suffix_list.dat'); + ηm.assets.purge(/./, 'public_suffix_list.dat'); } break; @@ -801,7 +801,7 @@ vAPI.messaging.listen('hosts-files.js', onMessage); (function() { -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ @@ -819,13 +819,13 @@ var restoreUserData = function(userData) { vAPI.storage.set({ userMatrix: userData.rules }, onCountdown); vAPI.storage.set({ liveHostsFiles: userData.hostsFiles }, onCountdown); if ( userData.rawSettings instanceof Object ) { - µMatrix.saveRawSettings(userData.rawSettings, onCountdown); + ηMatrix.saveRawSettings(userData.rawSettings, onCountdown); } }; // If we are going to restore all, might as well wipe out clean local // storage - µm.XAL.keyvalRemoveAll(onAllRemoved); + ηm.XAL.keyvalRemoveAll(onAllRemoved); }; /******************************************************************************/ @@ -834,7 +834,7 @@ var resetUserData = function() { var onAllRemoved = function() { vAPI.app.restart(); }; - µm.XAL.keyvalRemoveAll(onAllRemoved); + ηm.XAL.keyvalRemoveAll(onAllRemoved); }; /******************************************************************************/ @@ -855,17 +855,17 @@ var onMessage = function(request, sender, callback) { app: vAPI.app.name, version: vAPI.app.version, when: Date.now(), - settings: µm.userSettings, - rules: µm.pMatrix.toString(), - hostsFiles: µm.liveHostsFiles, - rawSettings: µm.rawSettings + settings: ηm.userSettings, + rules: ηm.pMatrix.toString(), + hostsFiles: ηm.liveHostsFiles, + rawSettings: ηm.rawSettings }; break; case 'getSomeStats': response = { version: vAPI.app.version, - storageUsed: µm.storageUsed + storageUsed: ηm.storageUsed }; break; @@ -895,7 +895,7 @@ vAPI.messaging.listen('about.js', onMessage); /******************************************************************************/ -var µm = µMatrix, +var ηm = ηMatrix, loggerURL = vAPI.getURL('logger-ui.html'); /******************************************************************************/ @@ -913,32 +913,32 @@ var onMessage = function(request, sender, callback) { switch ( request.what ) { case 'readMany': if ( - µm.logger.ownerId !== undefined && - request.ownerId !== µm.logger.ownerId + ηm.logger.ownerId !== undefined && + request.ownerId !== ηm.logger.ownerId ) { response = { unavailable: true }; break; } var tabIds = {}; - for ( var tabId in µm.pageStores ) { - var pageStore = µm.pageStoreFromTabId(tabId); + for ( var tabId in ηm.pageStores ) { + var pageStore = ηm.pageStoreFromTabId(tabId); if ( pageStore === null ) { continue; } if ( pageStore.rawUrl.startsWith(loggerURL) ) { continue; } tabIds[tabId] = pageStore.title || pageStore.rawUrl; } response = { colorBlind: false, - entries: µm.logger.readAll(request.ownerId), - maxLoggedRequests: µm.userSettings.maxLoggedRequests, + entries: ηm.logger.readAll(request.ownerId), + maxLoggedRequests: ηm.userSettings.maxLoggedRequests, noTabId: vAPI.noTabId, tabIds: tabIds, - tabIdsToken: µm.pageStoresToken + tabIdsToken: ηm.pageStoresToken }; break; case 'releaseView': - if ( request.ownerId === µm.logger.ownerId ) { - µm.logger.ownerId = undefined; + if ( request.ownerId === ηm.logger.ownerId ) { + ηm.logger.ownerId = undefined; } break; diff --git a/js/pagestats.js b/js/pagestats.js index 37e94c7..eb9a172 100644 --- a/js/pagestats.js +++ b/js/pagestats.js @@ -24,11 +24,11 @@ /******************************************************************************/ -µMatrix.pageStoreFactory = (function() { +ηMatrix.pageStoreFactory = (function() { /******************************************************************************/ -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ @@ -99,7 +99,7 @@ var PageStore = function(tabContext) { this.hostnameTypeCells = new Map(); this.domains = new Set(); this.blockedCollapsibles = new BlockedCollapsibles(); - this.requestStats = µm.requestStatsFactory(); + this.requestStats = ηm.requestStatsFactory(); this.off = false; this.init(tabContext); }; @@ -164,11 +164,11 @@ PageStore.prototype = { }, lookupBlockedCollapsibles: function(request, response) { - var tabContext = µm.tabContextManager.lookup(this.tabId); + var tabContext = ηm.tabContextManager.lookup(this.tabId); if ( tabContext === null ) { return; } - var collapseBlacklisted = µm.userSettings.collapseBlacklisted, - collapseBlocked = µm.userSettings.collapseBlocked, + var collapseBlacklisted = ηm.userSettings.collapseBlacklisted, + collapseBlocked = ηm.userSettings.collapseBlocked, entry; var blockedResources = response.blockedResources; @@ -178,8 +178,8 @@ PageStore.prototype = { request.toFilter.length !== 0 ) { var roothn = tabContext.rootHostname, - hnFromURI = µm.URI.hostnameFromURI, - tMatrix = µm.tMatrix; + hnFromURI = ηm.URI.hostnameFromURI, + tMatrix = ηm.tMatrix; for ( entry of request.toFilter ) { if ( tMatrix.mustBlock(roothn, hnFromURI(entry.url), entry.type) === false ) { continue; @@ -209,7 +209,7 @@ PageStore.prototype = { // - remember which hostname/type were seen // - count the number of distinct URLs for any given // hostname-type pair - var hostname = µm.URI.hostnameFromURI(url), + var hostname = ηm.URI.hostnameFromURI(url), key = hostname + ' ' + type, uids = this.hostnameTypeCells.get(key); if ( uids === undefined ) { @@ -226,8 +226,8 @@ PageStore.prototype = { // https://github.com/gorhill/httpswitchboard/issues/306 // If it is recorded locally, record globally - µm.requestStats.record(type, block); - µm.updateBadgeAsync(this.tabId); + ηm.requestStats.record(type, block); + ηm.updateBadgeAsync(this.tabId); if ( block !== false ) { this.perLoadBlockedRequestCount++; diff --git a/js/profiler.js b/js/profiler.js index 732403c..8cd7fba 100644 --- a/js/profiler.js +++ b/js/profiler.js @@ -49,7 +49,7 @@ var quickProfiler = (function() { count += 1; time += (now - tstart); if ( (now - lastlog) >= period ) { - console.log('µMatrix> %s: %s ms (%d samples)', prompt, avg().toFixed(3), count); + console.log('ηMatrix> %s: %s ms (%d samples)', prompt, avg().toFixed(3), count); lastlog = now; } }; diff --git a/js/start.js b/js/start.js index 051e58f..3ebb6bd 100644 --- a/js/start.js +++ b/js/start.js @@ -32,7 +32,7 @@ /******************************************************************************/ -var µm = µMatrix; +var ηm = ηMatrix; /******************************************************************************/ @@ -51,10 +51,10 @@ var processCallbackQueue = function(queue, callback) { /******************************************************************************/ var onAllDone = function() { - µm.webRequest.start(); + ηm.webRequest.start(); - µm.assets.addObserver(µm.assetObserver.bind(µm)); - µm.scheduleAssetUpdater(µm.userSettings.autoUpdate ? 7 * 60 * 1000 : 0); + ηm.assets.addObserver(ηm.assetObserver.bind(ηm)); + ηm.scheduleAssetUpdater(ηm.userSettings.autoUpdate ? 7 * 60 * 1000 : 0); vAPI.cloud.start([ 'myRulesPane' ]); }; @@ -67,7 +67,7 @@ var onTabsReady = function(tabs) { // console.debug('start.js > binding %d tabs', i); while ( i-- ) { tab = tabs[i]; - µm.tabContextManager.push(tab.id, tab.url, 'newURL'); + ηm.tabContextManager.push(tab.id, tab.url, 'newURL'); } onAllDone(); @@ -76,29 +76,29 @@ var onTabsReady = function(tabs) { /******************************************************************************/ var onUserSettingsLoaded = function() { - µm.loadHostsFiles(); + ηm.loadHostsFiles(); }; /******************************************************************************/ var onPSLReady = function() { - µm.loadUserSettings(onUserSettingsLoaded); - µm.loadRawSettings(); - µm.loadMatrix(); + ηm.loadUserSettings(onUserSettingsLoaded); + ηm.loadRawSettings(); + ηm.loadMatrix(); // rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the // normal way forbid binding behind the scene tab. // https://github.com/gorhill/httpswitchboard/issues/67 - µm.pageStores[vAPI.noTabId] = µm.pageStoreFactory(µm.tabContextManager.mustLookup(vAPI.noTabId)); - µm.pageStores[vAPI.noTabId].title = vAPI.i18n('statsPageDetailedBehindTheScenePage'); + ηm.pageStores[vAPI.noTabId] = ηm.pageStoreFactory(ηm.tabContextManager.mustLookup(vAPI.noTabId)); + ηm.pageStores[vAPI.noTabId].title = vAPI.i18n('statsPageDetailedBehindTheScenePage'); vAPI.tabs.getAll(onTabsReady); }; /******************************************************************************/ -processCallbackQueue(µm.onBeforeStartQueue, function() { - µm.loadPublicSuffixList(onPSLReady); +processCallbackQueue(ηm.onBeforeStartQueue, function() { + ηm.loadPublicSuffixList(onPSLReady); }); /******************************************************************************/ diff --git a/js/storage.js b/js/storage.js index c2ece8f..5440176 100644 --- a/js/storage.js +++ b/js/storage.js @@ -26,30 +26,30 @@ /******************************************************************************/ -µMatrix.getBytesInUse = function() { - var µm = this; +ηMatrix.getBytesInUse = function() { + var ηm = this; var getBytesInUseHandler = function(bytesInUse) { - µm.storageUsed = bytesInUse; + ηm.storageUsed = bytesInUse; }; // Not all WebExtension implementations support getBytesInUse(). if ( typeof vAPI.storage.getBytesInUse === 'function' ) { vAPI.storage.getBytesInUse(null, getBytesInUseHandler); } else { - µm.storageUsed = undefined; + ηm.storageUsed = undefined; } }; /******************************************************************************/ -µMatrix.saveUserSettings = function() { +ηMatrix.saveUserSettings = function() { this.XAL.keyvalSetMany( this.userSettings, this.getBytesInUse.bind(this) ); }; -µMatrix.loadUserSettings = function(callback) { - var µm = this; +ηMatrix.loadUserSettings = function(callback) { + var ηm = this; if ( typeof callback !== 'function' ) { callback = this.noopFunc; @@ -58,9 +58,9 @@ var settingsLoaded = function(store) { // console.log('storage.js > loaded user settings'); - µm.userSettings = store; + ηm.userSettings = store; - callback(µm.userSettings); + callback(ηm.userSettings); }; vAPI.storage.get(this.userSettings, settingsLoaded); @@ -68,27 +68,27 @@ /******************************************************************************/ -µMatrix.loadRawSettings = function() { - var µm = this; +ηMatrix.loadRawSettings = function() { + var ηm = this; var onLoaded = function(bin) { if ( !bin || bin.rawSettings instanceof Object === false ) { return; } for ( var key of Object.keys(bin.rawSettings) ) { if ( - µm.rawSettings.hasOwnProperty(key) === false || - typeof bin.rawSettings[key] !== typeof µm.rawSettings[key] + ηm.rawSettings.hasOwnProperty(key) === false || + typeof bin.rawSettings[key] !== typeof ηm.rawSettings[key] ) { continue; } - µm.rawSettings[key] = bin.rawSettings[key]; + ηm.rawSettings[key] = bin.rawSettings[key]; } - µm.rawSettingsWriteTime = Date.now(); + ηm.rawSettingsWriteTime = Date.now(); }; vAPI.storage.get('rawSettings', onLoaded); }; -µMatrix.saveRawSettings = function(rawSettings, callback) { +ηMatrix.saveRawSettings = function(rawSettings, callback) { var keys = Object.keys(rawSettings); if ( keys.length === 0 ) { if ( typeof callback === 'function' ) { @@ -108,7 +108,7 @@ this.rawSettingsWriteTime = Date.now(); }; -µMatrix.rawSettingsFromString = function(raw) { +ηMatrix.rawSettingsFromString = function(raw) { var result = {}, lineIter = new this.LineIterator(raw), line, matches, name, value; @@ -152,7 +152,7 @@ this.saveRawSettings(result); }; -µMatrix.stringFromRawSettings = function() { +ηMatrix.stringFromRawSettings = function() { var out = []; for ( var key of Object.keys(this.rawSettings).sort() ) { out.push(key + ' ' + this.rawSettings[key]); @@ -163,21 +163,21 @@ /******************************************************************************/ // save white/blacklist -µMatrix.saveMatrix = function() { - µMatrix.XAL.keyvalSetOne('userMatrix', this.pMatrix.toString()); +ηMatrix.saveMatrix = function() { + ηMatrix.XAL.keyvalSetOne('userMatrix', this.pMatrix.toString()); }; /******************************************************************************/ -µMatrix.loadMatrix = function(callback) { +ηMatrix.loadMatrix = function(callback) { if ( typeof callback !== 'function' ) { callback = this.noopFunc; } - var µm = this; + var ηm = this; var onLoaded = function(bin) { if ( bin.hasOwnProperty('userMatrix') ) { - µm.pMatrix.fromString(bin.userMatrix); - µm.tMatrix.assign(µm.pMatrix); + ηm.pMatrix.fromString(bin.userMatrix); + ηm.tMatrix.assign(ηm.pMatrix); callback(); } }; @@ -186,7 +186,7 @@ /******************************************************************************/ -µMatrix.listKeysFromCustomHostsFiles = function(raw) { +ηMatrix.listKeysFromCustomHostsFiles = function(raw) { var out = new Set(), reIgnore = /^[!#]/, reValid = /^[a-z-]+:\/\/\S+/, @@ -202,12 +202,12 @@ /******************************************************************************/ -µMatrix.getAvailableHostsFiles = function(callback) { - var µm = this, +ηMatrix.getAvailableHostsFiles = function(callback) { + var ηm = this, availableHostsFiles = {}; // Custom filter lists. - var importedListKeys = this.listKeysFromCustomHostsFiles(µm.userSettings.externalHostsFiles), + var importedListKeys = this.listKeysFromCustomHostsFiles(ηm.userSettings.externalHostsFiles), i = importedListKeys.length, listKey, entry; while ( i-- ) { @@ -250,8 +250,8 @@ if ( entry.submitter !== 'user' ) { continue; } if ( dict.has(assetKey) ) { continue; } delete availableHostsFiles[assetKey]; - µm.assets.unregisterAssetSource(assetKey); - µm.assets.remove(assetKey); + ηm.assets.unregisterAssetSource(assetKey); + ηm.assets.remove(assetKey); } callback(availableHostsFiles); @@ -278,8 +278,8 @@ /******************************************************************************/ -µMatrix.loadHostsFiles = function(callback) { - var µm = µMatrix; +ηMatrix.loadHostsFiles = function(callback) { + var ηm = ηMatrix; var hostsFileLoadCount; if ( typeof callback !== 'function' ) { @@ -287,15 +287,15 @@ } var loadHostsFilesEnd = function() { - µm.ubiquitousBlacklist.freeze(); - vAPI.storage.set({ 'liveHostsFiles': µm.liveHostsFiles }); + ηm.ubiquitousBlacklist.freeze(); + vAPI.storage.set({ 'liveHostsFiles': ηm.liveHostsFiles }); vAPI.messaging.broadcast({ what: 'loadHostsFilesCompleted' }); - µm.getBytesInUse(); + ηm.getBytesInUse(); callback(); }; var mergeHostsFile = function(details) { - µm.mergeHostsFile(details); + ηm.mergeHostsFile(details); hostsFileLoadCount -= 1; if ( hostsFileLoadCount === 0 ) { loadHostsFilesEnd(); @@ -303,8 +303,8 @@ }; var loadHostsFilesStart = function(hostsFiles) { - µm.liveHostsFiles = hostsFiles; - µm.ubiquitousBlacklist.reset(); + ηm.liveHostsFiles = hostsFiles; + ηm.ubiquitousBlacklist.reset(); var locations = Object.keys(hostsFiles); hostsFileLoadCount = locations.length; @@ -315,7 +315,7 @@ hostsFileLoadCount -= 1; continue; } - µm.assets.get(location, mergeHostsFile); + ηm.assets.get(location, mergeHostsFile); } // https://github.com/gorhill/uMatrix/issues/2 @@ -330,7 +330,7 @@ /******************************************************************************/ -µMatrix.mergeHostsFile = function(details) { +ηMatrix.mergeHostsFile = function(details) { var usedCount = this.ubiquitousBlacklist.count; var duplicateCount = this.ubiquitousBlacklist.duplicateCount; @@ -346,7 +346,7 @@ /******************************************************************************/ -µMatrix.mergeHostsFileContent = function(rawText) { +ηMatrix.mergeHostsFileContent = function(rawText) { var rawEnd = rawText.length; var ubiquitousBlacklist = this.ubiquitousBlacklist; var reLocalhost = /(^|\s)(localhost\.localdomain|localhost|local|broadcasthost|0\.0\.0\.0|127\.0\.0\.1|::1|fe80::1%lo0)(?=\s|$)/g; @@ -405,8 +405,8 @@ // `switches` contains the filter lists for which the switch must be revisited. -µMatrix.selectHostsFiles = function(details, callback) { - var µm = this, +ηMatrix.selectHostsFiles = function(details, callback) { + var ηm = this, externalHostsFiles = this.userSettings.externalHostsFiles, i, n, assetKey; @@ -450,7 +450,7 @@ // existing stock list. var assetKeyFromURL = function(url) { var needle = url.replace(/^https?:/, ''); - var assets = µm.liveHostsFiles, asset; + var assets = ηm.liveHostsFiles, asset; for ( var assetKey in assets ) { asset = assets[assetKey]; if ( asset.content !== 'filters' ) { continue; } @@ -503,13 +503,13 @@ // `switches` contains the preset blacklists for which the switch must be // revisited. -µMatrix.reloadHostsFiles = function() { +ηMatrix.reloadHostsFiles = function() { this.loadHostsFiles(); }; /******************************************************************************/ -µMatrix.loadPublicSuffixList = function(callback) { +ηMatrix.loadPublicSuffixList = function(callback) { if ( typeof callback !== 'function' ) { callback = this.noopFunc; } @@ -526,7 +526,7 @@ /******************************************************************************/ -µMatrix.scheduleAssetUpdater = (function() { +ηMatrix.scheduleAssetUpdater = (function() { var timer, next = 0; return function(updateDelay) { if ( timer ) { @@ -547,14 +547,14 @@ timer = vAPI.setTimeout(function() { timer = undefined; next = 0; - µMatrix.assets.updateStart({ delay: 120000 }); + ηMatrix.assets.updateStart({ delay: 120000 }); }, updateDelay); }; })(); /******************************************************************************/ -µMatrix.assetObserver = function(topic, details) { +ηMatrix.assetObserver = function(topic, details) { // Do not update filter list if not in use. if ( topic === 'before-asset-updated' ) { if ( @@ -29,13 +29,13 @@ /******************************************************************************/ -var µm = µMatrix; +var ηm = ηMatrix; // https://github.com/gorhill/httpswitchboard/issues/303 // Some kind of trick going on here: // Any scheme other than 'http' and 'https' is remapped into a fake -// URL which trick the rest of µMatrix into being able to process an -// otherwise unmanageable scheme. µMatrix needs web page to have a proper +// URL which trick the rest of ηMatrix into being able to process an +// otherwise unmanageable scheme. ηMatrix needs web page to have a proper // hostname to work properly, so just like the 'behind-the-scene' // fake domain name, we map unknown schemes into a fake '{scheme}-scheme' // hostname. This way, for a specific scheme you can create scope with @@ -44,7 +44,7 @@ var µm = µMatrix; /******************************************************************************/ /******************************************************************************/ -µm.normalizePageURL = function(tabId, pageURL) { +ηm.normalizePageURL = function(tabId, pageURL) { if ( vAPI.isBehindTheSceneTabId(tabId) ) { return 'http://' + this.behindTheSceneScope + '/'; } @@ -140,7 +140,7 @@ housekeep itself. */ -µm.tabContextManager = (function() { +ηm.tabContextManager = (function() { var tabContexts = Object.create(null); // https://github.com/chrisaljoudi/uBlock/issues/1001 @@ -227,7 +227,7 @@ housekeep itself. if ( i < this.stack.length ) { this.stack.length = i; this.update(); - µm.bindTabToPageStats(this.tabId, 'newURL'); + ηm.bindTabToPageStats(this.tabId, 'newURL'); } }; @@ -251,11 +251,11 @@ housekeep itself. return; } this.rawURL = this.stack[this.stack.length - 1].url; - this.normalURL = µm.normalizePageURL(this.tabId, this.rawURL); - this.scheme = µm.URI.schemeFromURI(this.rawURL); - this.rootHostname = µm.URI.hostnameFromURI(this.normalURL); - this.rootDomain = µm.URI.domainFromHostname(this.rootHostname) || this.rootHostname; - this.secure = µm.URI.isSecureScheme(this.scheme); + this.normalURL = ηm.normalizePageURL(this.tabId, this.rawURL); + this.scheme = ηm.URI.schemeFromURI(this.rawURL); + this.rootHostname = ηm.URI.hostnameFromURI(this.normalURL); + this.rootDomain = ηm.URI.domainFromHostname(this.rootHostname) || this.rootHostname; + this.secure = ηm.URI.isSecureScheme(this.scheme); }; // Called whenever a candidate root URL is spotted for the tab. @@ -280,7 +280,7 @@ housekeep itself. this.commitTimer = vAPI.setTimeout(this.onCommit.bind(this), 1000); } this.update(); - µm.bindTabToPageStats(this.tabId, context); + ηm.bindTabToPageStats(this.tabId, context); }; // These are to be used for the API of the tab context manager. @@ -342,9 +342,9 @@ housekeep itself. var entry = new TabContext(vAPI.noTabId); entry.stack.push(new StackEntry('', true)); entry.rawURL = ''; - entry.normalURL = µm.normalizePageURL(entry.tabId); - entry.rootHostname = µm.URI.hostnameFromURI(entry.normalURL); - entry.rootDomain = µm.URI.domainFromHostname(entry.rootHostname) || entry.rootHostname; + entry.normalURL = ηm.normalizePageURL(entry.tabId); + entry.rootHostname = ηm.URI.hostnameFromURI(entry.normalURL); + entry.rootDomain = ηm.URI.domainFromHostname(entry.rootHostname) || entry.rootHostname; })(); // https://github.com/gorhill/uMatrix/issues/513 @@ -356,7 +356,7 @@ housekeep itself. var tabId = details.tabId; if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; } push(tabId, details.url, 'newURL'); - µm.updateBadgeAsync(tabId); + ηm.updateBadgeAsync(tabId); }; // https://github.com/gorhill/uMatrix/issues/872 @@ -372,7 +372,7 @@ housekeep itself. }; vAPI.tabs.onClosed = function(tabId) { - µm.unbindTabFromPageStats(tabId); + ηm.unbindTabFromPageStats(tabId); var entry = tabContexts[tabId]; if ( entry instanceof TabContext ) { entry.destroy(); @@ -393,7 +393,7 @@ vAPI.tabs.registerListeners(); // Create an entry for the tab if it doesn't exist -µm.bindTabToPageStats = function(tabId, context) { +ηm.bindTabToPageStats = function(tabId, context) { this.updateBadgeAsync(tabId); // Do not create a page store for URLs which are of no interests @@ -454,7 +454,7 @@ vAPI.tabs.registerListeners(); /******************************************************************************/ -µm.unbindTabFromPageStats = function(tabId) { +ηm.unbindTabFromPageStats = function(tabId) { // Never unbind behind-the-scene page store. if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; @@ -489,7 +489,7 @@ vAPI.tabs.registerListeners(); /******************************************************************************/ -µm.resurrectPageStore = function(tabId, pageURL) { +ηm.resurrectPageStore = function(tabId, pageURL) { if ( this.pageStoreCemetery.hasOwnProperty(tabId) === false ) { return null; } @@ -516,7 +516,7 @@ vAPI.tabs.registerListeners(); /******************************************************************************/ -µm.incineratePageStore = function(tabId, pageURL) { +ηm.incineratePageStore = function(tabId, pageURL) { if ( this.pageStoreCemetery.hasOwnProperty(tabId) === false ) { return; } @@ -542,18 +542,18 @@ vAPI.tabs.registerListeners(); /******************************************************************************/ -µm.pageStoreFromTabId = function(tabId) { +ηm.pageStoreFromTabId = function(tabId) { return this.pageStores[tabId] || null; }; // Never return null -µm.mustPageStoreFromTabId = function(tabId) { +ηm.mustPageStoreFromTabId = function(tabId) { return this.pageStores[tabId] || this.pageStores[vAPI.noTabId]; }; /******************************************************************************/ -µm.forceReload = function(tabId, bypassCache) { +ηm.forceReload = function(tabId, bypassCache) { vAPI.tabs.reload(tabId, bypassCache); }; @@ -565,7 +565,7 @@ vAPI.tabs.registerListeners(); // incrementally, as chromium overwrite the icon at some point without // notifying me, and this causes internal cached state to be out of sync. -µm.updateBadgeAsync = (function() { +ηm.updateBadgeAsync = (function() { var tabIdToTimer = Object.create(null); var updateBadge = function(tabId) { @@ -604,7 +604,7 @@ vAPI.tabs.registerListeners(); /******************************************************************************/ -µm.updateTitle = (function() { +ηm.updateTitle = (function() { var tabIdToTimer = Object.create(null); var tabIdToTryCount = Object.create(null); var delay = 499; @@ -623,7 +623,7 @@ vAPI.tabs.registerListeners(); return false; } tabIdToTryCount[tabId] = count - 1; - tabIdToTimer[tabId] = vAPI.setTimeout(updateTitle.bind(µm, tabId), delay); + tabIdToTimer[tabId] = vAPI.setTimeout(updateTitle.bind(ηm, tabId), delay); return true; }; @@ -677,11 +677,11 @@ vAPI.tabs.registerListeners(); var cleanup = function() { var vapiTabs = vAPI.tabs; - var tabIds = Object.keys(µm.pageStores).sort(); + var tabIds = Object.keys(ηm.pageStores).sort(); var checkTab = function(tabId) { vapiTabs.get(tabId, function(tab) { if ( !tab ) { - µm.unbindTabFromPageStats(tabId); + ηm.unbindTabFromPageStats(tabId); } }); }; diff --git a/js/traffic.js b/js/traffic.js index 3e6a6ac..1ca12cd 100644 --- a/js/traffic.js +++ b/js/traffic.js @@ -26,34 +26,34 @@ // Start isolation from global scope -µMatrix.webRequest = (function() { +ηMatrix.webRequest = (function() { /******************************************************************************/ // Intercept and filter web requests according to white and black lists. var onBeforeRootFrameRequestHandler = function(details) { - var µm = µMatrix; + var ηm = ηMatrix; var requestURL = details.url; - var requestHostname = µm.URI.hostnameFromURI(requestURL); + var requestHostname = ηm.URI.hostnameFromURI(requestURL); var tabId = details.tabId; - µm.tabContextManager.push(tabId, requestURL); + ηm.tabContextManager.push(tabId, requestURL); - var tabContext = µm.tabContextManager.mustLookup(tabId); + var tabContext = ηm.tabContextManager.mustLookup(tabId); var rootHostname = tabContext.rootHostname; // Disallow request as per matrix? - var block = µm.mustBlock(rootHostname, requestHostname, 'doc'); + var block = ηm.mustBlock(rootHostname, requestHostname, 'doc'); - var pageStore = µm.pageStoreFromTabId(tabId); + var pageStore = ηm.pageStoreFromTabId(tabId); pageStore.recordRequest('doc', requestURL, block); - µm.logger.writeOne(tabId, 'net', rootHostname, requestURL, 'doc', block); + ηm.logger.writeOne(tabId, 'net', rootHostname, requestURL, 'doc', block); // Not blocked if ( !block ) { // rhill 2013-11-07: Senseless to do this for behind-the-scene requests. - µm.cookieHunter.recordPageCookies(pageStore); + ηm.cookieHunter.recordPageCookies(pageStore); return; } @@ -74,12 +74,12 @@ var onBeforeRootFrameRequestHandler = function(details) { // Intercept and filter web requests according to white and black lists. var onBeforeRequestHandler = function(details) { - var µm = µMatrix, - µmuri = µm.URI, + var ηm = ηMatrix, + ηmuri = ηm.URI, requestURL = details.url, - requestScheme = µmuri.schemeFromURI(requestURL); + requestScheme = ηmuri.schemeFromURI(requestURL); - if ( µmuri.isNetworkScheme(requestScheme) === false ) { return; } + if ( ηmuri.isNetworkScheme(requestScheme) === false ) { return; } var requestType = requestTypeNormalizer[details.type] || 'other'; @@ -92,24 +92,24 @@ var onBeforeRequestHandler = function(details) { // Re-classify orphan HTTP requests as behind-the-scene requests. There is // not much else which can be done, because there are URLs - // which cannot be handled by µMatrix, i.e. `opera://startpage`, + // which cannot be handled by ηMatrix, i.e. `opera://startpage`, // as this would lead to complications with no obvious solution, like how // to scope on unknown scheme? Etc. // https://github.com/gorhill/httpswitchboard/issues/191 // https://github.com/gorhill/httpswitchboard/issues/91#issuecomment-37180275 - var tabContext = µm.tabContextManager.mustLookup(details.tabId), + var tabContext = ηm.tabContextManager.mustLookup(details.tabId), tabId = tabContext.tabId, rootHostname = tabContext.rootHostname, specificity = 0; // Filter through matrix - var block = µm.tMatrix.mustBlock( + var block = ηm.tMatrix.mustBlock( rootHostname, - µmuri.hostnameFromURI(requestURL), + ηmuri.hostnameFromURI(requestURL), requestType ); if ( block ) { - specificity = µm.tMatrix.specificityRegister; + specificity = ηm.tMatrix.specificityRegister; } // Record request. @@ -118,18 +118,18 @@ var onBeforeRequestHandler = function(details) { // processing has already been performed, and that a synthetic URL has // been constructed for logging purpose. Use this synthetic URL if // it is available. - var pageStore = µm.mustPageStoreFromTabId(tabId); + var pageStore = ηm.mustPageStoreFromTabId(tabId); // Enforce strict secure connection? - if ( tabContext.secure && µmuri.isSecureScheme(requestScheme) === false ) { + if ( tabContext.secure && ηmuri.isSecureScheme(requestScheme) === false ) { pageStore.hasMixedContent = true; if ( block === false ) { - block = µm.tMatrix.evaluateSwitchZ('https-strict', rootHostname); + block = ηm.tMatrix.evaluateSwitchZ('https-strict', rootHostname); } } pageStore.recordRequest(requestType, requestURL, block); - µm.logger.writeOne(tabId, 'net', rootHostname, requestURL, details.type, block); + ηm.logger.writeOne(tabId, 'net', rootHostname, requestURL, details.type, block); if ( block ) { pageStore.cacheBlockedCollapsible(requestType, requestURL, specificity); @@ -142,13 +142,13 @@ var onBeforeRequestHandler = function(details) { // Sanitize outgoing headers as per user settings. var onBeforeSendHeadersHandler = function(details) { - var µm = µMatrix, - µmuri = µm.URI, + var ηm = ηMatrix, + ηmuri = ηm.URI, requestURL = details.url, - requestScheme = µmuri.schemeFromURI(requestURL); + requestScheme = ηmuri.schemeFromURI(requestURL); // Ignore non-network schemes - if ( µmuri.isNetworkScheme(requestScheme) === false ) { return; } + if ( ηmuri.isNetworkScheme(requestScheme) === false ) { return; } // Re-classify orphan HTTP requests as behind-the-scene requests. There is // not much else which can be done, because there are URLs @@ -158,7 +158,7 @@ var onBeforeSendHeadersHandler = function(details) { // https://github.com/gorhill/httpswitchboard/issues/191 // https://github.com/gorhill/httpswitchboard/issues/91#issuecomment-37180275 var tabId = details.tabId, - pageStore = µm.mustPageStoreFromTabId(tabId), + pageStore = ηm.mustPageStoreFromTabId(tabId), requestType = requestTypeNormalizer[details.type] || 'other', requestHeaders = details.requestHeaders, headerIndex, headerValue; @@ -188,11 +188,11 @@ var onBeforeSendHeadersHandler = function(details) { if ( headerIndex !== -1 ) { headerValue = requestHeaders[headerIndex].value; if ( headerValue !== '' ) { - var block = µm.userSettings.processHyperlinkAuditing; + var block = ηm.userSettings.processHyperlinkAuditing; pageStore.recordRequest('other', requestURL + '{Ping-To:' + headerValue + '}', block); - µm.logger.writeOne(tabId, 'net', '', requestURL, 'ping', block); + ηm.logger.writeOne(tabId, 'net', '', requestURL, 'ping', block); if ( block ) { - µm.hyperlinkAuditingFoiledCounter += 1; + ηm.hyperlinkAuditingFoiledCounter += 1; return { 'cancel': true }; } } @@ -202,7 +202,7 @@ var onBeforeSendHeadersHandler = function(details) { // is to sanitize headers. var rootHostname = pageStore.pageHostname, - requestHostname = µmuri.hostnameFromURI(requestURL), + requestHostname = ηmuri.hostnameFromURI(requestURL), modified = false; // Process `Cookie` header. @@ -210,14 +210,14 @@ var onBeforeSendHeadersHandler = function(details) { headerIndex = headerIndexFromName('cookie', requestHeaders); if ( headerIndex !== -1 && - µm.mustBlock(rootHostname, requestHostname, 'cookie') + ηm.mustBlock(rootHostname, requestHostname, 'cookie') ) { modified = true; headerValue = requestHeaders[headerIndex].value; requestHeaders.splice(headerIndex, 1); - µm.cookieHeaderFoiledCounter++; + ηm.cookieHeaderFoiledCounter++; if ( requestType === 'doc' ) { - µm.logger.writeOne(tabId, 'net', '', headerValue, 'COOKIE', true); + ηm.logger.writeOne(tabId, 'net', '', headerValue, 'COOKIE', true); } } @@ -245,10 +245,10 @@ var onBeforeSendHeadersHandler = function(details) { if ( headerIndex !== -1 ) { headerValue = requestHeaders[headerIndex].value; if ( headerValue !== '' ) { - var toDomain = µmuri.domainFromHostname(requestHostname); - if ( toDomain !== '' && toDomain !== µmuri.domainFromURI(headerValue) ) { + var toDomain = ηmuri.domainFromHostname(requestHostname); + if ( toDomain !== '' && toDomain !== ηmuri.domainFromURI(headerValue) ) { pageStore.has3pReferrer = true; - if ( µm.tMatrix.evaluateSwitchZ('referrer-spoof', rootHostname) ) { + if ( ηm.tMatrix.evaluateSwitchZ('referrer-spoof', rootHostname) ) { modified = true; var newValue; if ( details.method === 'GET' ) { @@ -257,11 +257,11 @@ var onBeforeSendHeadersHandler = function(details) { } else { requestHeaders.splice(headerIndex, 1); } - µm.refererHeaderFoiledCounter++; + ηm.refererHeaderFoiledCounter++; if ( requestType === 'doc' ) { - µm.logger.writeOne(tabId, 'net', '', headerValue, 'REFERER', true); + ηm.logger.writeOne(tabId, 'net', '', headerValue, 'REFERER', true); if ( newValue !== undefined ) { - µm.logger.writeOne(tabId, 'net', '', newValue, 'REFERER', false); + ηm.logger.writeOne(tabId, 'net', '', newValue, 'REFERER', false); } } } @@ -286,7 +286,7 @@ var onBeforeSendHeadersHandler = function(details) { var onHeadersReceived = function(details) { // Ignore schemes other than 'http...' - var µm = µMatrix, + var ηm = ηMatrix, tabId = details.tabId, requestURL = details.url, requestType = requestTypeNormalizer[details.type] || 'other'; @@ -294,36 +294,36 @@ var onHeadersReceived = function(details) { // https://github.com/gorhill/uMatrix/issues/145 // Check if the main_frame is a download if ( requestType === 'doc' ) { - µm.tabContextManager.push(tabId, requestURL); + ηm.tabContextManager.push(tabId, requestURL); } - var tabContext = µm.tabContextManager.lookup(tabId); + var tabContext = ηm.tabContextManager.lookup(tabId); if ( tabContext === null ) { return; } var csp = [], cspReport = [], rootHostname = tabContext.rootHostname, - requestHostname = µm.URI.hostnameFromURI(requestURL); + requestHostname = ηm.URI.hostnameFromURI(requestURL); // Inline script tags. - if ( µm.mustAllow(rootHostname, requestHostname, 'script' ) !== true ) { - csp.push(µm.cspNoInlineScript); + if ( ηm.mustAllow(rootHostname, requestHostname, 'script' ) !== true ) { + csp.push(ηm.cspNoInlineScript); } // Inline style tags. - if ( µm.mustAllow(rootHostname, requestHostname, 'css' ) !== true ) { - csp.push(µm.cspNoInlineStyle); + if ( ηm.mustAllow(rootHostname, requestHostname, 'css' ) !== true ) { + csp.push(ηm.cspNoInlineStyle); } // https://bugzilla.mozilla.org/show_bug.cgi?id=1302667 - var cspNoWorker = µm.cspNoWorker; + var cspNoWorker = ηm.cspNoWorker; if ( cspNoWorker === undefined ) { cspNoWorker = cspNoWorkerInit(); } - if ( µm.tMatrix.evaluateSwitchZ('no-workers', rootHostname) ) { + if ( ηm.tMatrix.evaluateSwitchZ('no-workers', rootHostname) ) { csp.push(cspNoWorker); - } else if ( µm.rawSettings.disableCSPReportInjection === false ) { + } else if ( ηm.rawSettings.disableCSPReportInjection === false ) { cspReport.push(cspNoWorker); } @@ -342,7 +342,7 @@ var onHeadersReceived = function(details) { }); } if ( requestType === 'doc' ) { - µm.logger.writeOne(tabId, 'net', '', cspDirectives, 'CSP', false); + ηm.logger.writeOne(tabId, 'net', '', cspDirectives, 'CSP', false); } } @@ -368,10 +368,10 @@ var cspNoWorkerInit = function() { if ( vAPI.webextFlavor === undefined ) { return "child-src 'none'; frame-src data: blob: *; report-uri about:blank"; } - µMatrix.cspNoWorker = /^Mozilla-Firefox-5[67]/.test(vAPI.webextFlavor) ? + ηMatrix.cspNoWorker = /^Mozilla-Firefox-5[67]/.test(vAPI.webextFlavor) ? "child-src 'none'; frame-src data: blob: *; report-uri about:blank" : "worker-src 'none'; report-uri about:blank" ; - return µMatrix.cspNoWorker; + return ηMatrix.cspNoWorker; }; /******************************************************************************/ diff --git a/js/uritools.js b/js/uritools.js index 2e50fd2..f3ca554 100644 --- a/js/uritools.js +++ b/js/uritools.js @@ -34,7 +34,7 @@ Naming convention from https://en.wikipedia.org/wiki/URI_scheme#Examples /******************************************************************************/ -µMatrix.URI = (function() { +ηMatrix.URI = (function() { /******************************************************************************/ @@ -167,7 +167,7 @@ URI.set = function(uri) { this.fragment = matches[5] !== undefined ? matches[5].slice(1) : ''; // Assume very simple authority, i.e. just a hostname (highest likelihood - // case for µMatrix) + // case for ηMatrix) if ( reHostFromNakedAuthority.test(this.authority) ) { this.hostname = this.authority; this.port = ''; @@ -286,7 +286,7 @@ URI.hostnameFromURI = function(uri) { matches = reAuthorityFromURI.exec(uri); if ( matches === null ) { return ''; } var authority = matches[1].slice(2); - // Assume very simple authority (most common case for µBlock) + // Assume very simple authority (most common case for ηBlock) if ( reHostFromNakedAuthority.test(authority) ) { return authority.toLowerCase(); } @@ -421,7 +421,7 @@ URI.domainFromURI = function(uri) { /******************************************************************************/ -// Normalize the way µMatrix expects it +// Normalize the way ηMatrix expects it URI.normalizedURI = function() { // Will be removed: diff --git a/js/usersettings.js b/js/usersettings.js index b5c5b51..13715f8 100644 --- a/js/usersettings.js +++ b/js/usersettings.js @@ -24,7 +24,7 @@ /******************************************************************************/ -µMatrix.changeUserSettings = function(name, value) { +ηMatrix.changeUserSettings = function(name, value) { if ( typeof name !== 'string' || name === '' ) { return; } diff --git a/js/utils.js b/js/utils.js index 3b1d170..ccd5e88 100644 --- a/js/utils.js +++ b/js/utils.js @@ -24,13 +24,13 @@ /******************************************************************************/ -µMatrix.gotoURL = function(details) { +ηMatrix.gotoURL = function(details) { vAPI.tabs.open(details); }; /******************************************************************************/ -µMatrix.gotoExtensionURL = function(details) { +ηMatrix.gotoExtensionURL = function(details) { if ( details.url.startsWith('logger-ui.html') ) { if ( details.shiftKey ) { this.changeUserSettings( @@ -46,13 +46,13 @@ /******************************************************************************/ -µMatrix.LineIterator = function(text, offset) { +ηMatrix.LineIterator = function(text, offset) { this.text = text; this.textLen = this.text.length; this.offset = offset || 0; }; -µMatrix.LineIterator.prototype = { +ηMatrix.LineIterator.prototype = { next: function() { var lineEnd = this.text.indexOf('\n', this.offset); if ( lineEnd === -1 ) { @@ -85,7 +85,7 @@ /******************************************************************************/ -µMatrix.setToArray = typeof Array.from === 'function' ? +ηMatrix.setToArray = typeof Array.from === 'function' ? Array.from : function(dict) { var out = [], @@ -99,7 +99,7 @@ return out; }; -µMatrix.setFromArray = function(arr) { +ηMatrix.setFromArray = function(arr) { return new Set(arr); }; diff --git a/js/vapi-background.js b/js/vapi-background.js index 363733c..7a49e9d 100644 --- a/js/vapi-background.js +++ b/js/vapi-background.js @@ -80,7 +80,7 @@ var deferUntil = function(testFn, mainFn, details) { /******************************************************************************/ vAPI.app = { - name: 'uMatrix', + name: 'eMatrix', version: location.hash.slice(1) }; @@ -130,7 +130,7 @@ window.addEventListener('unload', function() { if ( cleanupTasks.length < expectedNumberOfCleanups ) { console.error( - 'uMatrix> Cleanup tasks performed: %s (out of %s)', + 'eMatrix> Cleanup tasks performed: %s (out of %s)', cleanupTasks.length, expectedNumberOfCleanups ); @@ -817,7 +817,7 @@ vAPI.tabs.get = function(tabId, callback) { var tabBrowser = getTabBrowser(win); // https://github.com/gorhill/uMatrix/issues/540 - // The `index` property is nowhere used by uMatrix at this point, so we + // The `index` property is nowhere used by eMatrix at this point, so we // will refrain from returning this information for the time being. callback({ @@ -1535,7 +1535,7 @@ vAPI.messaging.onMessage = function({target, data}) { return; } - console.error('uMatrix> messaging > unknown request: %o', data); + console.error('eMatrix> messaging > unknown request: %o', data); // Unhandled: // Need to callback anyways in case caller expected an answer, or @@ -1798,7 +1798,7 @@ var httpObserver = { try { this.componentRegistrar.unregisterFactory(this.classID, Components.manager.getClassObject(this.classID, Ci.nsIFactory)); } catch (ex) { - console.error('uMatrix> httpObserver > unable to unregister stale instance: ', ex); + console.error('eMatrix> httpObserver > unable to unregister stale instance: ', ex); } } @@ -1952,7 +1952,7 @@ var httpObserver = { // https://github.com/gorhill/uMatrix/issues/165 // https://developer.mozilla.org/en-US/Firefox/Releases/3.5/Updating_extensions#Getting_a_load_context_from_a_request - // Not sure `umatrix:shouldLoad` is still needed, uMatrix does not + // Not sure `ematrix:shouldLoad` is still needed, eMatrix does not // care about embedded frames topography. // Also: // https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts @@ -2041,8 +2041,8 @@ var httpObserver = { // TODO: Find better place for this, needs to be set before onHeadersReceived.callback. // Web workers not blocked in Pale Moon as child-src currently unavailable, see: // https://github.com/MoonchildProductions/Pale-Moon/issues/949 - if ( µMatrix.cspNoWorker === undefined ) { - µMatrix.cspNoWorker = "child-src 'none'; frame-src data: blob: *; report-uri about:blank"; + if ( ηMatrix.cspNoWorker === undefined ) { + ηMatrix.cspNoWorker = "child-src 'none'; frame-src data: blob: *; report-uri about:blank"; } var result = vAPI.net.onHeadersReceived.callback({ @@ -2265,7 +2265,7 @@ vAPI.toolbarButton = { // Sanity check attempts = (attempts || 0) + 1; if ( attempts > 1/*000*/ ) { - //console.error('uMatrix> resizePopupDelayed: giving up after too many attempts'); + //console.error('eMatrix> resizePopupDelayed: giving up after too many attempts'); return false; } @@ -2381,7 +2381,7 @@ vAPI.toolbarButton = { } tbb.codePath = 'legacy'; - tbb.id = 'umatrix-legacy-button'; // NOTE: must match legacy-toolbar-button.css + tbb.id = 'ematrix-button'; // NOTE: must match legacy-toolbar-button.css tbb.viewId = tbb.id + '-panel'; var styleSheetUri = null; @@ -2411,7 +2411,7 @@ vAPI.toolbarButton = { }; var addLegacyToolbarButton = function(window) { - // uMatrix's stylesheet lazily added. + // eMatrix's stylesheet lazily added. if ( styleSheetUri === null ) { var sss = Cc["@mozilla.org/content/style-sheet-service;1"] .getService(Ci.nsIStyleSheetService); @@ -3108,7 +3108,7 @@ vAPI.contextMenu.remove = function() { /******************************************************************************/ var optionsObserver = (function() { - var addonId = 'uMatrix@raymondhill.net'; + var addonId = 'eMatrix@vannilla.org'; var commandHandler = function() { switch ( this.id ) { diff --git a/js/vapi-client.js b/js/vapi-client.js index fd77179..34a599f 100644 --- a/js/vapi-client.js +++ b/js/vapi-client.js @@ -34,8 +34,8 @@ /******************************************************************************/ // https://bugs.chromium.org/p/project-zero/issues/detail?id=1225&desc=6#c10 -if ( self.vAPI === undefined || self.vAPI.uMatrix !== true ) { - self.vAPI = { uMatrix: true }; +if ( self.vAPI === undefined || self.vAPI.eMatrix !== true ) { + self.vAPI = { eMatrix: true }; } var vAPI = self.vAPI; @@ -167,7 +167,7 @@ vAPI.messaging = { this.pending.set(message.requestId, callback); } - sendAsyncMessage('umatrix:background', message); + sendAsyncMessage('ematrix:background', message); }, toggleListener: function({type, persisted}) { diff --git a/js/vapi-common.js b/js/vapi-common.js index 3b51d17..8ef49bd 100644 --- a/js/vapi-common.js +++ b/js/vapi-common.js @@ -38,8 +38,8 @@ const {Services} = Components.utils.import( ); // https://bugs.chromium.org/p/project-zero/issues/detail?id=1225&desc=6#c10 -if ( self.vAPI === undefined || self.vAPI.uMatrix !== true ) { - self.vAPI = { uMatrix: true }; +if ( self.vAPI === undefined || self.vAPI.eMatrix !== true ) { + self.vAPI = { eMatrix: true }; } var vAPI = self.vAPI; @@ -20,11 +20,11 @@ uMatrix Home: https://github.com/gorhill/uMatrix */ -/* global chrome, µMatrix */ +/* global chrome, ηMatrix */ /******************************************************************************/ -µMatrix.XAL = (function(){ +ηMatrix.XAL = (function(){ /******************************************************************************/ |