mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-09-30 09:06:56 +13:00
add visual cue to hint at relevance of per-scope switches
This commit is contained in:
parent
dba034fd90
commit
19c32608f3
7 changed files with 105 additions and 58 deletions
|
@ -110,22 +110,36 @@ body .toolbar button.fa {
|
||||||
}
|
}
|
||||||
|
|
||||||
#mtxSwitches > li {
|
#mtxSwitches > li {
|
||||||
align-items: baseline;
|
align-items: center;
|
||||||
color: #888;
|
color: #888;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
|
||||||
}
|
}
|
||||||
#mtxSwitches > li.switchTrue {
|
#mtxSwitches > li.switchTrue {
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
#mtxSwitches > li > span:before {
|
#mtxSwitches > li > svg {
|
||||||
font: 110% FontAwesome;
|
display: inline;
|
||||||
|
height: 1em;
|
||||||
|
margin-right: 0.4em;
|
||||||
|
width: 1.5em;
|
||||||
}
|
}
|
||||||
#mtxSwitches > li > span:first-of-type:before {
|
#mtxSwitches > li > svg * {
|
||||||
content: '\f204\a0';
|
fill-opacity: 1;
|
||||||
|
opacity: 1;
|
||||||
|
stroke: none;
|
||||||
}
|
}
|
||||||
#mtxSwitches > li.switchTrue > span:first-of-type:before {
|
#mtxSwitches > li > svg .off,
|
||||||
content: '\f205\a0';
|
#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 > span[data-i18n] {
|
||||||
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
#mtxSwitches > li > a {
|
#mtxSwitches > li > a {
|
||||||
color: #000;
|
color: #000;
|
||||||
|
@ -143,7 +157,6 @@ body .toolbar button.fa {
|
||||||
border: 0;
|
border: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
display: none;
|
display: none;
|
||||||
font: 1rem httpsb,sans-serif;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
|
@ -90,11 +90,12 @@ var nameToStateMap = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var switchBitOffsets = new Map([
|
var switchBitOffsets = new Map([
|
||||||
[ 'matrix-off', 0 ],
|
[ 'matrix-off', 0 ],
|
||||||
[ 'https-strict', 2 ],
|
[ 'https-strict', 2 ],
|
||||||
/* 4 is now unused, formerly assigned to UA spoofing */
|
/* 4 is now unused, formerly assigned to UA spoofing */
|
||||||
[ 'referrer-spoof', 6 ],
|
[ 'referrer-spoof', 6 ],
|
||||||
[ 'noscript-spoof', 8 ]
|
[ 'noscript-spoof', 8 ],
|
||||||
|
[ 'no-workers', 10 ]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var switchStateToNameMap = new Map([
|
var switchStateToNameMap = new Map([
|
||||||
|
|
|
@ -164,6 +164,9 @@ var matrixSnapshot = function(pageStore, details) {
|
||||||
collapseBlacklistedDomains: µmuser.popupCollapseBlacklistedDomains,
|
collapseBlacklistedDomains: µmuser.popupCollapseBlacklistedDomains,
|
||||||
diff: [],
|
diff: [],
|
||||||
domain: pageStore.pageDomain,
|
domain: pageStore.pageDomain,
|
||||||
|
has3pReferrer: pageStore.has3pReferrer,
|
||||||
|
hasMixedContent: pageStore.hasMixedContent,
|
||||||
|
hasNoscriptTags: pageStore.hasNoscriptTags,
|
||||||
headerIndices: Array.from(headerIndices),
|
headerIndices: Array.from(headerIndices),
|
||||||
hostname: pageStore.pageHostname,
|
hostname: pageStore.pageHostname,
|
||||||
mtxContentModified: pageStore.mtxContentModifiedTime !== details.mtxContentModifiedTime,
|
mtxContentModified: pageStore.mtxContentModifiedTime !== details.mtxContentModifiedTime,
|
||||||
|
@ -508,8 +511,9 @@ var onMessage = function(request, sender, callback) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tabId = sender && sender.tab ? sender.tab.id || 0 : 0;
|
var tabId = sender && sender.tab ? sender.tab.id || 0 : 0,
|
||||||
var tabContext = µm.tabContextManager.lookup(tabId);
|
tabContext = µm.tabContextManager.lookup(tabId),
|
||||||
|
pageStore = µm.pageStoreFromTabId(tabId);
|
||||||
|
|
||||||
// Sync
|
// Sync
|
||||||
var response;
|
var response;
|
||||||
|
@ -528,10 +532,12 @@ var onMessage = function(request, sender, callback) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'mustRenderNoscriptTags?':
|
case 'mustRenderNoscriptTags?':
|
||||||
if ( tabContext !== null ) {
|
if ( tabContext === null ) { break; }
|
||||||
response =
|
response =
|
||||||
µm.tMatrix.mustBlock(tabContext.rootHostname, tabContext.rootHostname, 'script') &&
|
µm.tMatrix.mustBlock(tabContext.rootHostname, tabContext.rootHostname, 'script') &&
|
||||||
µm.tMatrix.evaluateSwitchZ('noscript-spoof', tabContext.rootHostname);
|
µm.tMatrix.evaluateSwitchZ('noscript-spoof', tabContext.rootHostname);
|
||||||
|
if ( pageStore !== null ) {
|
||||||
|
pageStore.hasNoscriptTags = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,9 @@ PageStore.prototype = {
|
||||||
this.distinctRequestCount = 0;
|
this.distinctRequestCount = 0;
|
||||||
this.perLoadAllowedRequestCount = 0;
|
this.perLoadAllowedRequestCount = 0;
|
||||||
this.perLoadBlockedRequestCount = 0;
|
this.perLoadBlockedRequestCount = 0;
|
||||||
|
this.has3pReferrer = false;
|
||||||
|
this.hasMixedContent = false;
|
||||||
|
this.hasNoscriptTags = false;
|
||||||
this.incinerationTimer = null;
|
this.incinerationTimer = null;
|
||||||
this.mtxContentModifiedTime = 0;
|
this.mtxContentModifiedTime = 0;
|
||||||
this.mtxCountModifiedTime = 0;
|
this.mtxCountModifiedTime = 0;
|
||||||
|
|
|
@ -1185,21 +1185,30 @@ function updateMatrixSwitches() {
|
||||||
enabled,
|
enabled,
|
||||||
switches = matrixSnapshot.tSwitches;
|
switches = matrixSnapshot.tSwitches;
|
||||||
for ( var switchName in switches ) {
|
for ( var switchName in switches ) {
|
||||||
if ( switches.hasOwnProperty(switchName) === false ) {
|
if ( switches.hasOwnProperty(switchName) === false ) { continue; }
|
||||||
continue;
|
|
||||||
}
|
|
||||||
enabled = switches[switchName];
|
enabled = switches[switchName];
|
||||||
if ( enabled && switchName !== 'matrix-off' ) {
|
if ( enabled && switchName !== 'matrix-off' ) {
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
uDom('#mtxSwitch_' + switchName).toggleClass('switchTrue', enabled);
|
uDom('#mtxSwitch_' + switchName).toggleClass('switchTrue', enabled);
|
||||||
}
|
}
|
||||||
uDom('#buttonMtxSwitches').descendants('span.badge').text(count.toLocaleString());
|
uDom.nodeFromId('mtxSwitch_https-strict').classList.toggle(
|
||||||
count = matrixSnapshot.blockedCount;
|
'relevant',
|
||||||
var button = uDom('#mtxSwitch_matrix-off');
|
matrixSnapshot.hasMixedContent
|
||||||
button.descendants('span.badge').text(count.toLocaleString());
|
);
|
||||||
button.attr('data-tip', button.attr('data-tip').replace('{{count}}', count));
|
uDom.nodeFromId('mtxSwitch_referrer-spoof').classList.toggle(
|
||||||
uDom('body').toggleClass('powerOff', switches['matrix-off']);
|
'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) {
|
function toggleMatrixSwitch(ev) {
|
||||||
|
|
|
@ -111,16 +111,6 @@ var onBeforeRequestHandler = function(details) {
|
||||||
specificity = µm.tMatrix.specificityRegister;
|
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.
|
// Record request.
|
||||||
// https://github.com/gorhill/httpswitchboard/issues/342
|
// https://github.com/gorhill/httpswitchboard/issues/342
|
||||||
// The way requests are handled now, it may happen at this point some
|
// 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
|
// been constructed for logging purpose. Use this synthetic URL if
|
||||||
// it is available.
|
// it is available.
|
||||||
var pageStore = µm.mustPageStoreFromTabId(tabId);
|
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);
|
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);
|
||||||
|
|
||||||
|
@ -244,25 +243,25 @@ var onBeforeSendHeadersHandler = function(details) {
|
||||||
headerIndex = headerIndexFromName('referer', requestHeaders);
|
headerIndex = headerIndexFromName('referer', requestHeaders);
|
||||||
if ( headerIndex !== -1 ) {
|
if ( headerIndex !== -1 ) {
|
||||||
headerValue = requestHeaders[headerIndex].value;
|
headerValue = requestHeaders[headerIndex].value;
|
||||||
if (
|
if ( headerValue !== '' ) {
|
||||||
headerValue !== '' &&
|
|
||||||
µm.tMatrix.evaluateSwitchZ('referrer-spoof', rootHostname)
|
|
||||||
) {
|
|
||||||
var toDomain = µmuri.domainFromHostname(requestHostname);
|
var toDomain = µmuri.domainFromHostname(requestHostname);
|
||||||
if ( toDomain !== '' && toDomain !== µmuri.domainFromURI(headerValue) ) {
|
if ( toDomain !== '' && toDomain !== µmuri.domainFromURI(headerValue) ) {
|
||||||
modified = true;
|
pageStore.has3pReferrer = true;
|
||||||
var newValue;
|
if ( µm.tMatrix.evaluateSwitchZ('referrer-spoof', rootHostname) ) {
|
||||||
if ( details.method === 'GET' ) {
|
modified = true;
|
||||||
newValue = requestHeaders[headerIndex].value =
|
var newValue;
|
||||||
requestScheme + '://' + requestHostname + '/';
|
if ( details.method === 'GET' ) {
|
||||||
} else {
|
newValue = requestHeaders[headerIndex].value =
|
||||||
requestHeaders.splice(headerIndex, 1);
|
requestScheme + '://' + requestHostname + '/';
|
||||||
}
|
} else {
|
||||||
µm.refererHeaderFoiledCounter++;
|
requestHeaders.splice(headerIndex, 1);
|
||||||
if ( requestType === 'doc' ) {
|
}
|
||||||
µm.logger.writeOne(tabId, 'net', '', headerValue, 'REFERER', true);
|
µm.refererHeaderFoiledCounter++;
|
||||||
if ( newValue !== undefined ) {
|
if ( requestType === 'doc' ) {
|
||||||
µm.logger.writeOne(tabId, 'net', '', newValue, 'REFERER', false);
|
µm.logger.writeOne(tabId, 'net', '', headerValue, 'REFERER', true);
|
||||||
|
if ( newValue !== undefined ) {
|
||||||
|
µm.logger.writeOne(tabId, 'net', '', newValue, 'REFERER', false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,22 @@
|
||||||
<div class="domainSeparator"></div>
|
<div class="domainSeparator"></div>
|
||||||
<div class="matRow"><div class="matCell"><b> </b> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div></div>
|
<div class="matRow"><div class="matCell"><b> </b> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div><div class="matCell"> </div></div>
|
||||||
<div id="cellHotspots"><div id="whitelist"></div><div id="blacklist"></div><div id="domainOnly"><span class="fa"></span></div></div>
|
<div id="cellHotspots"><div id="whitelist"></div><div id="blacklist"></div><div id="domainOnly"><span class="fa"></span></div></div>
|
||||||
|
<!-- Use once min supported browser version allows for use of CSS variables
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||||
|
<symbol id="toggleButton" viewBox="0 0 152 96">
|
||||||
|
<g>
|
||||||
|
<path d="m 48,24 a 24,24 0 0 0 -24,24 24,24 0 0 0 24,24 l 48,0 A 24,24 0 0 0 120,48 24,24 0 0 0 96,24 l -48,0 z" style="opacity:1;fill:#bbb;fill-opacity:1;stroke:none;" />
|
||||||
|
<g style="display:var(--off);">
|
||||||
|
<ellipse style="fill:#bbb;fill-opacity:1;stroke:none;" cx="48" cy="48" rx="48" ry="48" />
|
||||||
|
<ellipse style="opacity:1;fill:#fff;fill-opacity:1;stroke:none;" cx="48" cy="48" rx="40" ry="40" />
|
||||||
|
<ellipse style="display:var(--dot);fill:#bbb;fill-opacity:1;stroke:none;" cx="48" cy="48" rx="12" ry="12" /></g>
|
||||||
|
<g style="display:var(--on);">
|
||||||
|
<ellipse style="opacity:1;fill:#444;fill-opacity:1;stroke:none;" cx="104" cy="48" rx="48" ry="48" />
|
||||||
|
<ellipse style="display:var(--dot);fill:#bbb;fill-opacity:1;stroke:none;" cx="104" cy="48" rx="12" ry="12" /></g>
|
||||||
|
</g>
|
||||||
|
</symbol>
|
||||||
|
</svg>
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="paneHead">
|
<div class="paneHead">
|
||||||
|
@ -70,9 +86,9 @@
|
||||||
<div id="dropDownMenuSwitches" class="dropdown-menu-capture">
|
<div id="dropDownMenuSwitches" class="dropdown-menu-capture">
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<ul id="mtxSwitches">
|
<ul id="mtxSwitches">
|
||||||
<li id="mtxSwitch_https-strict" class="dropdown-menu-entry"><span data-i18n="matrixSwitchNoMixedContent"></span> <a class="fa" href="https://developer.mozilla.org/docs/Web/Security/Mixed_content" target="_blank"></a>
|
<li id="mtxSwitch_https-strict" class="dropdown-menu-entry exists"><!-- <svg><use xlink:href="#toggleButton" /></svg> --><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 152 96"><g><path d="m 48,24 a 24,24 0 0 0 -24,24 24,24 0 0 0 24,24 l 48,0 A 24,24 0 0 0 120,48 24,24 0 0 0 96,24 l -48,0 z" style="fill:#bbb;" /><g class="off"><ellipse style="fill:#bbb;" cx="48" cy="48" rx="48" ry="48" /><ellipse style="fill:#fff;" cx="48" cy="48" rx="40" ry="40" /><ellipse class="dot" style="fill:#bbb;" cx="48" cy="48" rx="12" ry="12" /></g><g class="on"><ellipse style="fill:#444;" cx="104" cy="48" rx="48" ry="48" /><ellipse class="dot" style="fill:#bbb;" cx="104" cy="48" rx="12" ry="12" /></g></g></svg><span data-i18n="matrixSwitchNoMixedContent"></span> <a class="fa" href="https://developer.mozilla.org/docs/Web/Security/Mixed_content" target="_blank"></a>
|
||||||
<li id="mtxSwitch_referrer-spoof" class="dropdown-menu-entry"><span data-i18n="matrixSwitchReferrerSpoof"></span> <a class="fa" href="https://developer.mozilla.org/docs/Web/HTTP/Headers/Referer" target="_blank"></a>
|
<li id="mtxSwitch_referrer-spoof" class="dropdown-menu-entry"><!-- <svg><use xlink:href="#toggleButton" /></svg> --><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 152 96"><g><path d="m 48,24 a 24,24 0 0 0 -24,24 24,24 0 0 0 24,24 l 48,0 A 24,24 0 0 0 120,48 24,24 0 0 0 96,24 l -48,0 z" style="fill:#bbb;" /><g class="off"><ellipse style="fill:#bbb;" cx="48" cy="48" rx="48" ry="48" /><ellipse style="fill:#fff;" cx="48" cy="48" rx="40" ry="40" /><ellipse class="dot" style="fill:#bbb;" cx="48" cy="48" rx="12" ry="12" /></g><g class="on"><ellipse style="fill:#444;" cx="104" cy="48" rx="48" ry="48" /><ellipse class="dot" style="fill:#bbb;" cx="104" cy="48" rx="12" ry="12" /></g></g></svg><span data-i18n="matrixSwitchReferrerSpoof"></span> <a class="fa" href="https://developer.mozilla.org/docs/Web/HTTP/Headers/Referer" target="_blank"></a>
|
||||||
<li id="mtxSwitch_noscript-spoof" class="dropdown-menu-entry"><span data-i18n="matrixSwitchNoscriptSpoof"></span> <a class="fa" href="https://developer.mozilla.org/docs/Web/HTML/Element/noscript" target="_blank"></a>
|
<li id="mtxSwitch_noscript-spoof" class="dropdown-menu-entry"><!-- <svg><use xlink:href="#toggleButton" /></svg> --><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 152 96"><g><path d="m 48,24 a 24,24 0 0 0 -24,24 24,24 0 0 0 24,24 l 48,0 A 24,24 0 0 0 120,48 24,24 0 0 0 96,24 l -48,0 z" style="fill:#bbb;" /><g class="off"><ellipse style="fill:#bbb;" cx="48" cy="48" rx="48" ry="48" /><ellipse style="fill:#fff;" cx="48" cy="48" rx="40" ry="40" /><ellipse class="dot" style="fill:#bbb;" cx="48" cy="48" rx="12" ry="12" /></g><g class="on"><ellipse style="fill:#444;" cx="104" cy="48" rx="48" ry="48" /><ellipse class="dot" style="fill:#bbb;" cx="104" cy="48" rx="12" ry="12" /></g></g></svg><span data-i18n="matrixSwitchNoscriptSpoof"></span> <a class="fa" href="https://developer.mozilla.org/docs/Web/HTML/Element/noscript" target="_blank"></a>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue