mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-16 23:42:39 +01:00
Fall back to "Basic" when removing all-urls
from "No filtering"
Related discussion: https://github.com/uBlockOrigin/uBOL-home/issues/156#issuecomment-2254576670
This commit is contained in:
parent
0cc8b7864f
commit
9562b19a93
@ -19,18 +19,17 @@
|
|||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* jshint esversion:11 */
|
import {
|
||||||
|
TRUSTED_DIRECTIVE_BASE_RULE_ID,
|
||||||
'use strict';
|
getDynamicRules,
|
||||||
|
} from './ruleset-manager.js';
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
adminRead,
|
||||||
browser,
|
browser,
|
||||||
dnr,
|
dnr,
|
||||||
localRead, localWrite, localRemove,
|
localRead, localRemove, localWrite,
|
||||||
sessionRead, sessionWrite,
|
sessionRead, sessionWrite,
|
||||||
adminRead,
|
|
||||||
} from './ext.js';
|
} from './ext.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -40,11 +39,6 @@ import {
|
|||||||
toBroaderHostname,
|
toBroaderHostname,
|
||||||
} from './utils.js';
|
} from './utils.js';
|
||||||
|
|
||||||
import {
|
|
||||||
TRUSTED_DIRECTIVE_BASE_RULE_ID,
|
|
||||||
getDynamicRules
|
|
||||||
} from './ruleset-manager.js';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// 0: no filtering
|
// 0: no filtering
|
||||||
@ -288,13 +282,15 @@ async function writeFilteringModeDetails(afterDetails) {
|
|||||||
|
|
||||||
async function filteringModesToDNR(modes) {
|
async function filteringModesToDNR(modes) {
|
||||||
const dynamicRuleMap = await getDynamicRules();
|
const dynamicRuleMap = await getDynamicRules();
|
||||||
const presentRule = dynamicRuleMap.get(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
|
const trustedRule = dynamicRuleMap.get(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
|
||||||
const presentNone = new Set(
|
const trustedDomainSet = new Set(trustedRule?.condition.requestDomains);
|
||||||
presentRule && presentRule.condition.requestDomains
|
if ( trustedDomainSet.size !== 0 ) {
|
||||||
);
|
if ( eqSets(trustedDomainSet, modes.none) ) { return; }
|
||||||
if ( eqSets(presentNone, modes.none) ) { return; }
|
} else if ( trustedRule !== undefined ) {
|
||||||
|
if ( modes.none.has('all-urls') ) { return; }
|
||||||
|
}
|
||||||
const removeRuleIds = [];
|
const removeRuleIds = [];
|
||||||
if ( presentRule !== undefined ) {
|
if ( trustedRule !== undefined ) {
|
||||||
removeRuleIds.push(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
|
removeRuleIds.push(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
|
||||||
removeRuleIds.push(TRUSTED_DIRECTIVE_BASE_RULE_ID+1);
|
removeRuleIds.push(TRUSTED_DIRECTIVE_BASE_RULE_ID+1);
|
||||||
dynamicRuleMap.delete(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
|
dynamicRuleMap.delete(TRUSTED_DIRECTIVE_BASE_RULE_ID+0);
|
||||||
@ -394,6 +390,11 @@ export async function setTrustedSites(hostnames) {
|
|||||||
const { none } = filteringModes;
|
const { none } = filteringModes;
|
||||||
const hnSet = new Set(hostnames);
|
const hnSet = new Set(hostnames);
|
||||||
let modified = false;
|
let modified = false;
|
||||||
|
// Set default mode to Basic when removing No-filtering as default mode
|
||||||
|
if ( none.has('all-urls') && hnSet.has('all-urls') === false ) {
|
||||||
|
applyFilteringMode(filteringModes, 'all-urls', MODE_BASIC);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
for ( const hn of none ) {
|
for ( const hn of none ) {
|
||||||
if ( hnSet.has(hn) ) {
|
if ( hnSet.has(hn) ) {
|
||||||
hnSet.delete(hn);
|
hnSet.delete(hn);
|
||||||
|
Loading…
Reference in New Issue
Block a user