Add: exclude the entire site command
This commit is contained in:
parent
c009dde027
commit
494641da34
|
@ -316,7 +316,10 @@
|
||||||
"description": "Label for the button to enable a style"
|
"description": "Label for the button to enable a style"
|
||||||
},
|
},
|
||||||
"excludeStyleByDomainLabel": {
|
"excludeStyleByDomainLabel": {
|
||||||
"message": "Exclude this site"
|
"message": "Exclude by current domain"
|
||||||
|
},
|
||||||
|
"excludeStyleBySiteLabel": {
|
||||||
|
"message": "Exclude the entire site"
|
||||||
},
|
},
|
||||||
"excludeStyleByUrlLabel": {
|
"excludeStyleByUrlLabel": {
|
||||||
"message": "Exclude by current URL-prefix"
|
"message": "Exclude by current URL-prefix"
|
||||||
|
|
11
popup.html
11
popup.html
|
@ -48,6 +48,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
|
<label class="menu-item exclude-by-site button">
|
||||||
|
<div class="menu-icon">
|
||||||
|
<div class="checkbox-container">
|
||||||
|
<input type="checkbox" class="exclude-by-site-checkbox">
|
||||||
|
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span i18n-text="excludeStyleBySiteLabel"></span>
|
||||||
|
</label>
|
||||||
<label class="menu-item exclude-by-domain button">
|
<label class="menu-item exclude-by-domain button">
|
||||||
<div class="menu-icon">
|
<div class="menu-icon">
|
||||||
<div class="checkbox-container">
|
<div class="checkbox-container">
|
||||||
|
@ -171,6 +180,8 @@
|
||||||
<script src="vendor-overwrites/colorpicker/colorconverter.js"></script>
|
<script src="vendor-overwrites/colorpicker/colorconverter.js"></script>
|
||||||
<script src="vendor-overwrites/colorpicker/colorpicker.js"></script>
|
<script src="vendor-overwrites/colorpicker/colorpicker.js"></script>
|
||||||
|
|
||||||
|
<script src="vendor/psl/psl.min.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="msgbox/msgbox.css">
|
<link rel="stylesheet" href="msgbox/msgbox.css">
|
||||||
<script src="msgbox/msgbox.js"></script>
|
<script src="msgbox/msgbox.js"></script>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* global configDialog hotkeys onTabReady msg
|
/* global configDialog hotkeys onTabReady msg
|
||||||
getActiveTab FIREFOX getTabRealURL URLS API onDOMready $ $$ prefs CHROME
|
getActiveTab FIREFOX getTabRealURL URLS API onDOMready $ $$ prefs CHROME
|
||||||
setupLivePrefs template t $create tWordBreak animateElement
|
setupLivePrefs template t $create tWordBreak animateElement
|
||||||
tryJSONparse debounce */
|
tryJSONparse debounce psl */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -312,6 +312,7 @@ function createStyleElement(style) {
|
||||||
|
|
||||||
$('.menu-button', entry).onclick = handleEvent.toggleMenu;
|
$('.menu-button', entry).onclick = handleEvent.toggleMenu;
|
||||||
|
|
||||||
|
$('.exclude-by-site-checkbox', entry).onchange = e => handleEvent.toggleExclude(e, 'site');
|
||||||
$('.exclude-by-domain-checkbox', entry).onchange = e => handleEvent.toggleExclude(e, 'domain');
|
$('.exclude-by-domain-checkbox', entry).onchange = e => handleEvent.toggleExclude(e, 'domain');
|
||||||
$('.exclude-by-url-checkbox', entry).onchange = e => handleEvent.toggleExclude(e, 'url');
|
$('.exclude-by-url-checkbox', entry).onchange = e => handleEvent.toggleExclude(e, 'url');
|
||||||
}
|
}
|
||||||
|
@ -337,6 +338,9 @@ function createStyleElement(style) {
|
||||||
$('.exclude-by-domain-checkbox', entry).checked = styleExcluded(style, 'domain');
|
$('.exclude-by-domain-checkbox', entry).checked = styleExcluded(style, 'domain');
|
||||||
$('.exclude-by-domain', entry).title = getExcludeRule('domain');
|
$('.exclude-by-domain', entry).title = getExcludeRule('domain');
|
||||||
|
|
||||||
|
$('.exclude-by-site-checkbox', entry).checked = styleExcluded(style, 'site');
|
||||||
|
$('.exclude-by-site', entry).title = getExcludeRule('site');
|
||||||
|
|
||||||
const excludeByUrlCheckbox = $('.exclude-by-url-checkbox', entry);
|
const excludeByUrlCheckbox = $('.exclude-by-url-checkbox', entry);
|
||||||
const isRedundant = getExcludeRule('domain') === getExcludeRule('url');
|
const isRedundant = getExcludeRule('domain') === getExcludeRule('url');
|
||||||
excludeByUrlCheckbox.checked = !isRedundant && styleExcluded(style, 'url');
|
excludeByUrlCheckbox.checked = !isRedundant && styleExcluded(style, 'url');
|
||||||
|
@ -361,11 +365,19 @@ function styleExcluded({exclusions}, type) {
|
||||||
function getExcludeRule(type) {
|
function getExcludeRule(type) {
|
||||||
const u = new URL(tabURL);
|
const u = new URL(tabURL);
|
||||||
if (type === 'domain') {
|
if (type === 'domain') {
|
||||||
return u.protocol + '//*.' + u.host + '/*';
|
return u.protocol + '//' + u.host + '/*';
|
||||||
|
}
|
||||||
|
if (type === 'site') {
|
||||||
|
// FIXME: what should we do if `getRootDomain` return undefined?
|
||||||
|
return u.protocol + '//*.' + getRootDomain(u.host) + '/*';
|
||||||
}
|
}
|
||||||
return escapeGlob(u.origin + u.pathname) + '*';
|
return escapeGlob(u.origin + u.pathname) + '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRootDomain(domain) {
|
||||||
|
return psl.parse(domain).domain;
|
||||||
|
}
|
||||||
|
|
||||||
function escapeGlob(text) {
|
function escapeGlob(text) {
|
||||||
return text.replace(/\*/g, '\\*');
|
return text.replace(/\*/g, '\\*');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user