[mv3] Disable "strict blocking" by default in Safari

Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/428#issuecomment-3172663563
This commit is contained in:
Raymond Hill 2025-08-10 11:40:08 -04:00
parent 07e9f805bb
commit 19a3de901c
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
3 changed files with 28 additions and 1 deletions

View file

@ -58,6 +58,7 @@ import {
browser,
localRead, localRemove, localWrite,
runtime,
webextFlavor,
} from './ext.js';
import {
@ -106,6 +107,18 @@ function getCurrentVersion() {
return runtime.getManifest().version;
}
// The goal is just to be able to find out whether a specific version is older
// than another one.
function intFromVersion(version) {
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
if ( match === null ) { return 0; }
const year = parseInt(match[1], 10);
const monthday = parseInt(match[2], 10);
const min = parseInt(match[3], 10);
return (year - 2022) * (1232 * 2400) + monthday * 2400 + min;
}
/******************************************************************************/
async function onPermissionsRemoved() {
@ -542,6 +555,13 @@ async function startSession() {
// obsolete ruleset to remove.
if ( isNewVersion ) {
ubolLog(`Version change: ${rulesetConfig.version} => ${currentVersion}`);
// https://github.com/uBlockOrigin/uBOL-home/issues/428#issuecomment-3172663563
if ( webextFlavor === 'safari' && rulesetConfig.strictBlockMode ) {
const before = intFromVersion(rulesetConfig.version);
if ( before <= intFromVersion('2025.804.2359') ) {
rulesetConfig.strictBlockMode = false;
}
}
rulesetConfig.version = currentVersion;
await patchDefaultRulesets();
saveRulesetConfig();

View file

@ -22,6 +22,7 @@
import {
localRead, localWrite,
sessionRead, sessionWrite,
webextFlavor,
} from './ext.js';
/******************************************************************************/
@ -31,7 +32,7 @@ export const rulesetConfig = {
enabledRulesets: [],
autoReload: true,
showBlockedCount: true,
strictBlockMode: true,
strictBlockMode: webextFlavor !== 'safari',
developerMode: false,
hasBroadHostPermissions: true,
};

View file

@ -27,6 +27,12 @@ export const browser = webext;
export const i18n = browser.i18n;
export const runtime = browser.runtime;
export const webextFlavor = (( ) => {
const extURL = runtime.getURL('');
if ( extURL.startsWith('safari-web-extension:') ) { return 'safari'; }
return extURL.startsWith('moz-extension:') ? 'firefox' : 'chromium';
})();
/******************************************************************************/
// The extension's service worker can be evicted at any time, so when we