Skip to content

Commit

Permalink
MV3: fix cosmetic filter injection (#1364)
Browse files Browse the repository at this point in the history
* MV3: fix cosmetic filter injection
  • Loading branch information
chrmod authored Nov 2, 2023
1 parent f4ca329 commit 7e1ee02
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion extension-manifest-v3/src/background/adblocker.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ async function injectScriptlets(tabId, url) {

if (__PLATFORM__ === 'safari') {
chrome.runtime.onMessage.addListener((msg, sender) => {
if (sender.url && msg.action === 'onCommitted') {
if (sender.url && msg.action === 'injectScriptlets') {
injectScriptlets(sender.tab.id, sender.url);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Should only be needed on Safari:
// the tabId of the initial chrome.webNavigation.onCommitted
// is not reliable. When opening bookmarks, it can happen that
// the event is associated with a tabId of 0.
chrome.runtime.sendMessage({ action: 'injectScriptlets' });
3 changes: 2 additions & 1 deletion extension-manifest-v3/src/manifest.chromium.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"run_at": "document_start",
"js": [
"content_scripts/adblocker.js"
]
],
"all_frames": true
},
{
"matches": ["http://*/*", "https://*/*"],
Expand Down
3 changes: 2 additions & 1 deletion extension-manifest-v3/src/manifest.firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"run_at": "document_start",
"js": [
"content_scripts/adblocker.js"
]
],
"all_frames": true
},
{
"matches": ["http://*/*", "https://*/*"],
Expand Down
8 changes: 8 additions & 0 deletions extension-manifest-v3/src/manifest.safari.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@
"run_at": "document_start",
"js": [
"content_scripts/adblocker.js"
],
"all_frames": true
},
{
"matches": ["http://*/*", "https://*/*"],
"run_at": "document_start",
"js": [
"content_scripts/adblocker-scriptlets.js"
]
},
{
Expand Down

0 comments on commit 7e1ee02

Please sign in to comment.