summaryrefslogtreecommitdiffstats
path: root/platform/mv3/extension/js/mode-manager.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:18 +0000
commit55a5d29a66503248916f249ad2a1d8b37cde5a03 (patch)
treea3beb6a90dd3bdaaf67ecb05d42152a494aff946 /platform/mv3/extension/js/mode-manager.js
parentAdding upstream version 1.55.0+dfsg. (diff)
downloadublock-origin-55a5d29a66503248916f249ad2a1d8b37cde5a03.tar.xz
ublock-origin-55a5d29a66503248916f249ad2a1d8b37cde5a03.zip
Adding upstream version 1.57.0+dfsg.upstream/1.57.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'platform/mv3/extension/js/mode-manager.js')
-rw-r--r--platform/mv3/extension/js/mode-manager.js45
1 files changed, 32 insertions, 13 deletions
diff --git a/platform/mv3/extension/js/mode-manager.js b/platform/mv3/extension/js/mode-manager.js
index bc76199..e75dbee 100644
--- a/platform/mv3/extension/js/mode-manager.js
+++ b/platform/mv3/extension/js/mode-manager.js
@@ -288,34 +288,53 @@ async function writeFilteringModeDetails(afterDetails) {
async function filteringModesToDNR(modes) {
const dynamicRuleMap = await getDynamicRules();
- const presentRule = dynamicRuleMap.get(TRUSTED_DIRECTIVE_BASE_RULE_ID);
+ const presentRule = dynamicRuleMap.get(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
const presentNone = new Set(
presentRule && presentRule.condition.requestDomains
);
if ( eqSets(presentNone, modes.none) ) { return; }
const removeRuleIds = [];
if ( presentRule !== undefined ) {
- removeRuleIds.push(TRUSTED_DIRECTIVE_BASE_RULE_ID);
- dynamicRuleMap.delete(TRUSTED_DIRECTIVE_BASE_RULE_ID);
+ removeRuleIds.push(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
+ removeRuleIds.push(TRUSTED_DIRECTIVE_BASE_RULE_ID+1);
+ dynamicRuleMap.delete(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
+ dynamicRuleMap.delete(TRUSTED_DIRECTIVE_BASE_RULE_ID+1);
}
const addRules = [];
- if ( modes.none.size !== 0 ) {
- const rule = {
- id: TRUSTED_DIRECTIVE_BASE_RULE_ID,
+ const noneHostnames = [ ...modes.none ];
+ const notNoneHostnames = [ ...modes.basic, ...modes.optimal, ...modes.complete ];
+ if ( noneHostnames.length !== 0 ) {
+ const rule0 = {
+ id: TRUSTED_DIRECTIVE_BASE_RULE_ID+0,
action: { type: 'allowAllRequests' },
condition: {
resourceTypes: [ 'main_frame' ],
},
priority: 100,
};
- if (
- modes.none.size !== 1 ||
- modes.none.has('all-urls') === false
- ) {
- rule.condition.requestDomains = Array.from(modes.none);
+ if ( modes.none.has('all-urls') === false ) {
+ rule0.condition.requestDomains = noneHostnames.slice();
+ } else if ( notNoneHostnames.length !== 0 ) {
+ rule0.condition.excludedRequestDomains = notNoneHostnames.slice();
}
- addRules.push(rule);
- dynamicRuleMap.set(TRUSTED_DIRECTIVE_BASE_RULE_ID, rule);
+ addRules.push(rule0);
+ dynamicRuleMap.set(TRUSTED_DIRECTIVE_BASE_RULE_ID+0, rule0);
+ // https://github.com/uBlockOrigin/uBOL-home/issues/114
+ const rule1 = {
+ id: TRUSTED_DIRECTIVE_BASE_RULE_ID+1,
+ action: { type: 'allow' },
+ condition: {
+ resourceTypes: [ 'script' ],
+ },
+ priority: 100,
+ };
+ if ( modes.none.has('all-urls') === false ) {
+ rule1.condition.initiatorDomains = noneHostnames.slice();
+ } else if ( notNoneHostnames.length !== 0 ) {
+ rule1.condition.excludedInitiatorDomains = notNoneHostnames.slice();
+ }
+ addRules.push(rule1);
+ dynamicRuleMap.set(TRUSTED_DIRECTIVE_BASE_RULE_ID+1, rule1);
}
const updateOptions = {};
if ( addRules.length ) {