Add: support inclusions (#1359)
* Add: support inclusions * Fix: refresh settings page after configuring in popup
This commit is contained in:
parent
9ab5369393
commit
e23077a7ea
|
@ -193,6 +193,7 @@ const styleMan = (() => {
|
||||||
for (const style of styles) {
|
for (const style of styles) {
|
||||||
let excluded = false;
|
let excluded = false;
|
||||||
let excludedScheme = false;
|
let excludedScheme = false;
|
||||||
|
let included = false;
|
||||||
let sloppy = false;
|
let sloppy = false;
|
||||||
let sectionMatched = false;
|
let sectionMatched = false;
|
||||||
const match = urlMatchStyle(query, style);
|
const match = urlMatchStyle(query, style);
|
||||||
|
@ -200,6 +201,9 @@ const styleMan = (() => {
|
||||||
// if (match === false) {
|
// if (match === false) {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
if (match === 'included') {
|
||||||
|
included = true;
|
||||||
|
}
|
||||||
if (match === 'excluded') {
|
if (match === 'excluded') {
|
||||||
excluded = true;
|
excluded = true;
|
||||||
}
|
}
|
||||||
|
@ -219,8 +223,9 @@ const styleMan = (() => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sectionMatched) {
|
if (sectionMatched || included) {
|
||||||
result.push(/** @namespace StylesByUrlResult */ {style, excluded, sloppy, excludedScheme});
|
result.push(/** @namespace StylesByUrlResult */ {
|
||||||
|
style, excluded, sloppy, excludedScheme, sectionMatched, included});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -472,7 +477,12 @@ const styleMan = (() => {
|
||||||
|
|
||||||
// get styles matching a URL, including sloppy regexps and excluded items.
|
// get styles matching a URL, including sloppy regexps and excluded items.
|
||||||
function getAppliedCode(query, data) {
|
function getAppliedCode(query, data) {
|
||||||
if (urlMatchStyle(query, data) !== true) {
|
const result = urlMatchStyle(query, data);
|
||||||
|
if (result === 'included') {
|
||||||
|
// return all sections
|
||||||
|
return data.sections.map(s => s.code);
|
||||||
|
}
|
||||||
|
if (result !== true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const code = [];
|
const code = [];
|
||||||
|
@ -568,6 +578,12 @@ const styleMan = (() => {
|
||||||
if (!colorScheme.shouldIncludeStyle(style)) {
|
if (!colorScheme.shouldIncludeStyle(style)) {
|
||||||
return 'excludedScheme';
|
return 'excludedScheme';
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
style.inclusions &&
|
||||||
|
style.inclusions.some(r => compileExclusion(r).test(query.urlWithoutParams))
|
||||||
|
) {
|
||||||
|
return 'included';
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ function StyleSettings(editor) {
|
||||||
|
|
||||||
function update(newStyle, reason) {
|
function update(newStyle, reason) {
|
||||||
if (!newStyle.id) return;
|
if (!newStyle.id) return;
|
||||||
if (reason === 'editSave' || reason === 'config') return;
|
if (reason === 'editSave') return;
|
||||||
style = newStyle;
|
style = newStyle;
|
||||||
$('.style-settings').disabled = false;
|
$('.style-settings').disabled = false;
|
||||||
inputs.forEach(i => i.update());
|
inputs.forEach(i => i.update());
|
||||||
|
|
|
@ -380,6 +380,7 @@ function createStyleElement(style) {
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
entry.classList.toggle('force-applied', style.included);
|
||||||
entry.classList.toggle('not-applied', style.excluded || style.sloppy || style.excludedScheme);
|
entry.classList.toggle('not-applied', style.excluded || style.sloppy || style.excludedScheme);
|
||||||
entry.classList.toggle('regexp-partial', style.sloppy);
|
entry.classList.toggle('regexp-partial', style.sloppy);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user