diff --git a/package-lock.json b/package-lock.json index aed59b0f9..4640906fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "10.4.17", "license": "MPL-2.0", "dependencies": { - "@duckduckgo/autoconsent": "^10.17.0", + "@duckduckgo/autoconsent": "^12.2.0", "@ghostery/adblocker": "^2.1.1", "@ghostery/adblocker-webextension": "^2.1.1", "@github/relative-time-element": "^4.4.4", @@ -412,12 +412,14 @@ } }, "node_modules/@duckduckgo/autoconsent": { - "version": "10.17.0", - "resolved": "https://registry.npmjs.org/@duckduckgo/autoconsent/-/autoconsent-10.17.0.tgz", - "integrity": "sha512-zMB4BE5fpiqvjXPA0k8bCorWgh6eFMlkedRfuRVQYhbWqwLgrnsA7lv4U0ORTIJkvbBjABuYaprwr1yd/15D/w==", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@duckduckgo/autoconsent/-/autoconsent-12.2.0.tgz", + "integrity": "sha512-KhvkdhqTHqVxMxxmadWcW9E1WoGV06YIwVC2m8RIeJYk6AD2wIyO5MjP24moRG5OIvWohEhge8TU0OHeY0P6Tw==", "license": "MPL-2.0", "dependencies": { - "tldts-experimental": "^6.1.37" + "@ghostery/adblocker": "^2.0.4", + "@ghostery/adblocker-content": "^2.0.4", + "tldts-experimental": "^6.1.41" } }, "node_modules/@esbuild/aix-ppc64": { diff --git a/package.json b/package.json index 5ebf9443c..6a1d9b708 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "webextension-polyfill": "^0.12.0" }, "dependencies": { - "@duckduckgo/autoconsent": "^10.17.0", + "@duckduckgo/autoconsent": "^12.2.0", "@ghostery/adblocker": "^2.1.1", "@ghostery/adblocker-webextension": "^2.1.1", "@github/relative-time-element": "^4.4.4", diff --git a/src/background/autoconsent.js b/src/background/autoconsent.js index 93f251798..c4f8bfbac 100644 --- a/src/background/autoconsent.js +++ b/src/background/autoconsent.js @@ -10,7 +10,7 @@ */ import rules from '@duckduckgo/autoconsent/rules/rules.json'; -import { snippets } from '@duckduckgo/autoconsent/lib/eval-snippets'; + import { parse } from 'tldts-experimental'; import { store } from 'hybrids'; @@ -35,9 +35,7 @@ async function initialize(msg, tab, frameId) { enableCosmeticRules: false, }, }, - { - frameId, - }, + { frameId }, ); } catch { // The error is thrown when the tab is not ready to receive messages, @@ -46,44 +44,10 @@ async function initialize(msg, tab, frameId) { } } -async function evalCode(snippetId, id, tabId, frameId) { - const [result] = await chrome.scripting.executeScript({ - target: { - tabId, - frameIds: [frameId], - }, - world: - chrome.scripting.ExecutionWorld?.MAIN ?? - (__PLATFORM__ === 'firefox' ? undefined : 'MAIN'), - func: snippets[snippetId], - }); - - await chrome.tabs.sendMessage( - tabId, - { - action: 'autoconsent', - id, - type: 'evalResp', - result: result.result, - }, - { - frameId, - }, - ); -} - chrome.runtime.onMessage.addListener((msg, sender) => { - if (msg.action !== 'autoconsent') return; - if (!sender.tab) return; - - const frameId = sender.frameId; + if (msg.action !== 'autoconsent' || !sender.tab) return; - switch (msg.type) { - case 'init': - return initialize(msg, sender.tab, frameId); - case 'eval': - return evalCode(msg.snippetId, msg.id, sender.tab.id, frameId); - default: - break; + if (msg.type === 'init') { + initialize(msg, sender.tab, sender.frameId); } });