mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-21 18:02:34 +01:00
[mv3] Set Optimal as default if extension broad permission at install time
This is to prepare uBOL to be ready to set Optimal mode as default if ever Chromium-based browsers support a way to pre-grant broad host permissions in a policy. Related issue: https://github.com/uBlockOrigin/uBOL-home/discussions/232 https://github.com/uBlockOrigin/uBOL-home/discussions/135
This commit is contained in:
parent
89c353640e
commit
27f3612fdf
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user