diff --git a/src/css/popup.css b/src/css/popup.css index b13ac77..cd33a61 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -110,22 +110,36 @@ body .toolbar button.fa { } #mtxSwitches > li { - align-items: baseline; + align-items: center; color: #888; display: flex; - justify-content: space-between; } #mtxSwitches > li.switchTrue { color: #000; } -#mtxSwitches > li > span:before { - font: 110% FontAwesome; +#mtxSwitches > li > svg { + display: inline; + height: 1em; + margin-right: 0.4em; + width: 1.5em; + } +#mtxSwitches > li > svg * { + fill-opacity: 1; + opacity: 1; + stroke: none; } -#mtxSwitches > li > span:first-of-type:before { - content: '\f204\a0'; +#mtxSwitches > li > svg .off, +#mtxSwitches > li.switchTrue > svg .on, +#mtxSwitches > li.relevant > svg .dot { + display: block; + } +#mtxSwitches > li > svg .on, +#mtxSwitches > li > svg .dot, +#mtxSwitches > li.switchTrue > svg .off { + display: none; } -#mtxSwitches > li.switchTrue > span:first-of-type:before { - content: '\f205\a0'; +#mtxSwitches > li > span[data-i18n] { + flex-grow: 1; } #mtxSwitches > li > a { color: #000; @@ -143,7 +157,6 @@ body .toolbar button.fa { border: 0; bottom: 0; display: none; - font: 1rem httpsb,sans-serif; left: 0; margin: 0; padding: 0; diff --git a/src/js/matrix.js b/src/js/matrix.js index 24650ff..641c9e3 100644 --- a/src/js/matrix.js +++ b/src/js/matrix.js @@ -90,11 +90,12 @@ var nameToStateMap = { }; var switchBitOffsets = new Map([ - [ 'matrix-off', 0 ], - [ 'https-strict', 2 ], + [ 'matrix-off', 0 ], + [ 'https-strict', 2 ], /* 4 is now unused, formerly assigned to UA spoofing */ - [ 'referrer-spoof', 6 ], - [ 'noscript-spoof', 8 ] + [ 'referrer-spoof', 6 ], + [ 'noscript-spoof', 8 ], + [ 'no-workers', 10 ] ]); var switchStateToNameMap = new Map([ diff --git a/src/js/messaging.js b/src/js/messaging.js index 0ba9672..5f30192 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -164,6 +164,9 @@ var matrixSnapshot = function(pageStore, details) { collapseBlacklistedDomains: µmuser.popupCollapseBlacklistedDomains, diff: [], domain: pageStore.pageDomain, + has3pReferrer: pageStore.has3pReferrer, + hasMixedContent: pageStore.hasMixedContent, + hasNoscriptTags: pageStore.hasNoscriptTags, headerIndices: Array.from(headerIndices), hostname: pageStore.pageHostname, mtxContentModified: pageStore.mtxContentModifiedTime !== details.mtxContentModifiedTime, @@ -508,8 +511,9 @@ var onMessage = function(request, sender, callback) { break; } - var tabId = sender && sender.tab ? sender.tab.id || 0 : 0; - var tabContext = µm.tabContextManager.lookup(tabId); + var tabId = sender && sender.tab ? sender.tab.id || 0 : 0, + tabContext = µm.tabContextManager.lookup(tabId), + pageStore = µm.pageStoreFromTabId(tabId); // Sync var response; @@ -528,10 +532,12 @@ var onMessage = function(request, sender, callback) { break; case 'mustRenderNoscriptTags?': - if ( tabContext !== null ) { - response = - µm.tMatrix.mustBlock(tabContext.rootHostname, tabContext.rootHostname, 'script') && - µm.tMatrix.evaluateSwitchZ('noscript-spoof', tabContext.rootHostname); + if ( tabContext === null ) { break; } + response = + µm.tMatrix.mustBlock(tabContext.rootHostname, tabContext.rootHostname, 'script') && + µm.tMatrix.evaluateSwitchZ('noscript-spoof', tabContext.rootHostname); + if ( pageStore !== null ) { + pageStore.hasNoscriptTags = true; } break; diff --git a/src/js/pagestats.js b/src/js/pagestats.js index af01c64..65aaac8 100644 --- a/src/js/pagestats.js +++ b/src/js/pagestats.js @@ -123,6 +123,9 @@ PageStore.prototype = { this.distinctRequestCount = 0; this.perLoadAllowedRequestCount = 0; this.perLoadBlockedRequestCount = 0; + this.has3pReferrer = false; + this.hasMixedContent = false; + this.hasNoscriptTags = false; this.incinerationTimer = null; this.mtxContentModifiedTime = 0; this.mtxCountModifiedTime = 0; diff --git a/src/js/popup.js b/src/js/popup.js index 6e6c395..aac39a6 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -1185,21 +1185,30 @@ function updateMatrixSwitches() { enabled, switches = matrixSnapshot.tSwitches; for ( var switchName in switches ) { - if ( switches.hasOwnProperty(switchName) === false ) { - continue; - } + if ( switches.hasOwnProperty(switchName) === false ) { continue; } enabled = switches[switchName]; if ( enabled && switchName !== 'matrix-off' ) { count += 1; } uDom('#mtxSwitch_' + switchName).toggleClass('switchTrue', enabled); } - uDom('#buttonMtxSwitches').descendants('span.badge').text(count.toLocaleString()); - count = matrixSnapshot.blockedCount; - var button = uDom('#mtxSwitch_matrix-off'); - button.descendants('span.badge').text(count.toLocaleString()); - button.attr('data-tip', button.attr('data-tip').replace('{{count}}', count)); - uDom('body').toggleClass('powerOff', switches['matrix-off']); + uDom.nodeFromId('mtxSwitch_https-strict').classList.toggle( + 'relevant', + matrixSnapshot.hasMixedContent + ); + uDom.nodeFromId('mtxSwitch_referrer-spoof').classList.toggle( + 'relevant', + matrixSnapshot.has3pReferrer + ); + uDom.nodeFromId('mtxSwitch_noscript-spoof').classList.toggle( + 'relevant', + matrixSnapshot.hasNoscriptTags + ); + uDom.nodeFromSelector('#buttonMtxSwitches span.badge').textContent = + count.toLocaleString(); + uDom.nodeFromSelector('#mtxSwitch_matrix-off span.badge').textContent = + matrixSnapshot.blockedCount.toLocaleString(); + document.body.classList.toggle('powerOff', switches['matrix-off']); } function toggleMatrixSwitch(ev) { diff --git a/src/js/traffic.js b/src/js/traffic.js index 42a2c02..d77e10e 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -111,16 +111,6 @@ var onBeforeRequestHandler = function(details) { specificity = µm.tMatrix.specificityRegister; } - // Enforce strict secure connection? - if ( - block === false && - tabContext.secure && - µmuri.isSecureScheme(requestScheme) === false && - µm.tMatrix.evaluateSwitchZ('https-strict', rootHostname) - ) { - block = true; - } - // Record request. // https://github.com/gorhill/httpswitchboard/issues/342 // The way requests are handled now, it may happen at this point some @@ -128,6 +118,15 @@ var onBeforeRequestHandler = function(details) { // been constructed for logging purpose. Use this synthetic URL if // it is available. var pageStore = µm.mustPageStoreFromTabId(tabId); + + // Enforce strict secure connection? + if ( tabContext.secure && µmuri.isSecureScheme(requestScheme) === false ) { + pageStore.hasMixedContent = true; + if ( block === false ) { + block = µm.tMatrix.evaluateSwitchZ('https-strict', rootHostname); + } + } + pageStore.recordRequest(requestType, requestURL, block); µm.logger.writeOne(tabId, 'net', rootHostname, requestURL, details.type, block); @@ -244,25 +243,25 @@ var onBeforeSendHeadersHandler = function(details) { headerIndex = headerIndexFromName('referer', requestHeaders); if ( headerIndex !== -1 ) { headerValue = requestHeaders[headerIndex].value; - if ( - headerValue !== '' && - µm.tMatrix.evaluateSwitchZ('referrer-spoof', rootHostname) - ) { + if ( headerValue !== '' ) { var toDomain = µmuri.domainFromHostname(requestHostname); if ( toDomain !== '' && toDomain !== µmuri.domainFromURI(headerValue) ) { - modified = true; - var newValue; - if ( details.method === 'GET' ) { - newValue = requestHeaders[headerIndex].value = - requestScheme + '://' + requestHostname + '/'; - } else { - requestHeaders.splice(headerIndex, 1); - } - µm.refererHeaderFoiledCounter++; - if ( requestType === 'doc' ) { - µm.logger.writeOne(tabId, 'net', '', headerValue, 'REFERER', true); - if ( newValue !== undefined ) { - µm.logger.writeOne(tabId, 'net', '', newValue, 'REFERER', false); + pageStore.has3pReferrer = true; + if ( µm.tMatrix.evaluateSwitchZ('referrer-spoof', rootHostname) ) { + modified = true; + var newValue; + if ( details.method === 'GET' ) { + newValue = requestHeaders[headerIndex].value = + requestScheme + '://' + requestHostname + '/'; + } else { + requestHeaders.splice(headerIndex, 1); + } + µm.refererHeaderFoiledCounter++; + if ( requestType === 'doc' ) { + µm.logger.writeOne(tabId, 'net', '', headerValue, 'REFERER', true); + if ( newValue !== undefined ) { + µm.logger.writeOne(tabId, 'net', '', newValue, 'REFERER', false); + } } } } diff --git a/src/popup.html b/src/popup.html index 457a9e7..dd4a6f1 100644 --- a/src/popup.html +++ b/src/popup.html @@ -16,6 +16,22 @@
 
 
 
 
 
 
 
 
+
@@ -70,9 +86,9 @@