Skip to content

Commit 19a3de9

Browse files
committed
[mv3] Disable "strict blocking" by default in Safari
Related issue: uBlockOrigin/uBOL-home#428 (comment)
1 parent 07e9f80 commit 19a3de9

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

platform/mv3/extension/js/background.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
browser,
5959
localRead, localRemove, localWrite,
6060
runtime,
61+
webextFlavor,
6162
} from './ext.js';
6263

6364
import {
@@ -106,6 +107,18 @@ function getCurrentVersion() {
106107
return runtime.getManifest().version;
107108
}
108109

110+
// The goal is just to be able to find out whether a specific version is older
111+
// than another one.
112+
113+
function intFromVersion(version) {
114+
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
115+
if ( match === null ) { return 0; }
116+
const year = parseInt(match[1], 10);
117+
const monthday = parseInt(match[2], 10);
118+
const min = parseInt(match[3], 10);
119+
return (year - 2022) * (1232 * 2400) + monthday * 2400 + min;
120+
}
121+
109122
/******************************************************************************/
110123

111124
async function onPermissionsRemoved() {
@@ -542,6 +555,13 @@ async function startSession() {
542555
// obsolete ruleset to remove.
543556
if ( isNewVersion ) {
544557
ubolLog(`Version change: ${rulesetConfig.version} => ${currentVersion}`);
558+
// https://github.com/uBlockOrigin/uBOL-home/issues/428#issuecomment-3172663563
559+
if ( webextFlavor === 'safari' && rulesetConfig.strictBlockMode ) {
560+
const before = intFromVersion(rulesetConfig.version);
561+
if ( before <= intFromVersion('2025.804.2359') ) {
562+
rulesetConfig.strictBlockMode = false;
563+
}
564+
}
545565
rulesetConfig.version = currentVersion;
546566
await patchDefaultRulesets();
547567
saveRulesetConfig();

platform/mv3/extension/js/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import {
2323
localRead, localWrite,
2424
sessionRead, sessionWrite,
25+
webextFlavor,
2526
} from './ext.js';
2627

2728
/******************************************************************************/
@@ -31,7 +32,7 @@ export const rulesetConfig = {
3132
enabledRulesets: [],
3233
autoReload: true,
3334
showBlockedCount: true,
34-
strictBlockMode: true,
35+
strictBlockMode: webextFlavor !== 'safari',
3536
developerMode: false,
3637
hasBroadHostPermissions: true,
3738
};

platform/mv3/extension/js/ext.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export const browser = webext;
2727
export const i18n = browser.i18n;
2828
export const runtime = browser.runtime;
2929

30+
export const webextFlavor = (( ) => {
31+
const extURL = runtime.getURL('');
32+
if ( extURL.startsWith('safari-web-extension:') ) { return 'safari'; }
33+
return extURL.startsWith('moz-extension:') ? 'firefox' : 'chromium';
34+
})();
35+
3036
/******************************************************************************/
3137

3238
// The extension's service worker can be evicted at any time, so when we

0 commit comments

Comments
 (0)