diff --git a/platform/mv3/extension/js/background.js b/platform/mv3/extension/js/background.js index c8183e925..791625d2a 100644 --- a/platform/mv3/extension/js/background.js +++ b/platform/mv3/extension/js/background.js @@ -38,6 +38,8 @@ import { } from './ruleset-manager.js'; import { + MODE_BASIC, + MODE_OPTIMAL, getDefaultFilteringMode, getFilteringMode, getTrustedSites, @@ -136,7 +138,7 @@ async function onPermissionsRemoved() { const modified = await syncWithBrowserPermissions(); if ( modified === false ) { return false; } const afterMode = await getDefaultFilteringMode(); - if ( beforeMode > 1 && afterMode <= 1 ) { + if ( beforeMode > MODE_BASIC && afterMode <= MODE_BASIC ) { updateDynamicRules(); } registerInjectables(); @@ -420,9 +422,19 @@ async function start() { ); if ( firstRun ) { + const enableOptimal = await hasOmnipotence(); + if ( enableOptimal ) { + const afterLevel = await setDefaultFilteringMode(MODE_OPTIMAL); + if ( afterLevel === MODE_OPTIMAL ) { + updateDynamicRules(); + registerInjectables(); + } + } const disableFirstRunPage = await adminRead('disableFirstRunPage'); if ( disableFirstRunPage !== true ) { runtime.openOptionsPage(); + } else { + firstRun = false; } } } diff --git a/platform/mv3/extension/js/settings.js b/platform/mv3/extension/js/settings.js index 6f50055df..c916c4657 100644 --- a/platform/mv3/extension/js/settings.js +++ b/platform/mv3/extension/js/settings.js @@ -316,7 +316,7 @@ dom.on('#showBlockedCount input[type="checkbox"]', 'change', ev => { function renderTrustedSites() { const textarea = qs$('#trustedSites'); - const hostnames = cachedRulesetData.trustedSites; + const hostnames = cachedRulesetData.trustedSites || []; textarea.value = hostnames.map(hn => punycode.toUnicode(hn)).join('\n'); if ( textarea.value !== '' ) { textarea.value += '\n'; @@ -325,7 +325,7 @@ function renderTrustedSites() { function changeTrustedSites() { const hostnames = getStagedTrustedSites(); - const hash = hashFromIterable(cachedRulesetData.trustedSites); + const hash = hashFromIterable(cachedRulesetData.trustedSites || []); if ( hashFromIterable(hostnames) === hash ) { return; } sendMessage({ what: 'setTrustedSites',