Fix: disable redundant exclude-by-url checkbox

This commit is contained in:
eight 2019-02-13 10:07:40 +08:00
parent 9101ee9219
commit f7d0853f84
3 changed files with 17 additions and 1 deletions

View File

@ -321,6 +321,9 @@
"excludeStyleByUrlLabel": { "excludeStyleByUrlLabel": {
"message": "Exclude the current URL" "message": "Exclude the current URL"
}, },
"excludeStyleByUrlRedundant": {
"message": "The current URL is the domain page"
},
"exportLabel": { "exportLabel": {
"message": "Export", "message": "Export",
"description": "Label for the button to export a style ('edit' page) or all styles ('manage' page)" "description": "Label for the button to export a style ('edit' page) or all styles ('manage' page)"

View File

@ -367,6 +367,10 @@ a.configure[target="_blank"] .svg-icon.config {
display: block; display: block;
margin: 0 auto; margin: 0 auto;
} }
.entry .menu-item.disabled {
opacity: 0.5;
background-color: transparent;
}
/* checkbox */ /* checkbox */
.checkbox-container { .checkbox-container {

View File

@ -335,7 +335,16 @@ function createStyleElement(style) {
entry.classList.toggle('regexp-partial', style.sloppy); entry.classList.toggle('regexp-partial', style.sloppy);
$('.exclude-by-domain-checkbox', entry).checked = styleExcluded(style, 'domain'); $('.exclude-by-domain-checkbox', entry).checked = styleExcluded(style, 'domain');
$('.exclude-by-url-checkbox', entry).checked = styleExcluded(style, 'url');
const excludeByUrlCheckbox = $('.exclude-by-url-checkbox', entry);
const isRedundant = getExcludeRule('domain') === getExcludeRule('url');
excludeByUrlCheckbox.checked = !isRedundant && styleExcluded(style, 'url');
excludeByUrlCheckbox.disabled = isRedundant;
const excludeByUrlLabel = $('.exclude-by-url', entry);
excludeByUrlLabel.classList.toggle('disabled', isRedundant);
excludeByUrlLabel.title = isRedundant ?
chrome.i18n.getMessage('excludeStyleByUrlRedundant') : '';
return entry; return entry;
} }