From fea05dc65086ba23d24395bf0c1e6905852aa6c6 Mon Sep 17 00:00:00 2001 From: Slava Leleka Date: Fri, 13 Sep 2024 13:53:46 +0300 Subject: [PATCH] update aliases and compatibility table Squashed commit of the following: commit 94ac7abb143e718eb33c3e6820b84cb2b19c9880 Author: Slava Leleka Date: Fri Sep 13 13:21:15 2024 +0300 fix tests due to no aliases commit 48d209b78d297ceaabfdba7b689004204912a149 Author: Slava Leleka Date: Fri Sep 13 13:14:41 2024 +0300 update aliases for prevent-adfly commit 3c29417401b078582be0096ffcfe22d2c6dac6d0 Author: Slava Leleka Date: Fri Sep 13 01:22:08 2024 +0300 fix test commit 0a0d590e5d19155aa9634f113f3e560422afdb95 Author: Slava Leleka Date: Fri Sep 13 01:19:41 2024 +0300 update aliases for prevent-fetch commit 3b074a878b53e993d72a8118836958d7f6cd593b Author: Slava Leleka Date: Fri Sep 13 01:15:46 2024 +0300 no ubo alias support for trusted-replace-node-text commit ff22189a2de4677477d2f61727297405259e4dab Author: Slava Leleka Date: Fri Sep 13 01:10:15 2024 +0300 fix newline commit 8bda13abe01461cb56b5a597a39675b5fd6d41d1 Merge: a403bb27 39ae8a6d Author: Slava Leleka Date: Fri Sep 13 01:09:17 2024 +0300 Merge branch 'master' into fix/compatibility-table-03 commit a403bb277a76ef692f06273f1d4fd28a225d3099 Merge: e992735e d8d25ec6 Author: Slava Leleka Date: Thu Aug 8 17:36:40 2024 +0300 Merge branch 'master' into fix/compatibility-table-03 commit e992735e0367a867bd7364a04f2fba1830948f1b Author: Slava Leleka Date: Wed Apr 24 16:45:50 2024 +0400 cleanup compatibility table --- scripts/compatibility-table.json | 24 ++----------- src/redirects/prevent-bab.js | 1 + src/scriptlets/prevent-adfly.js | 5 +-- src/scriptlets/prevent-bab.js | 2 +- src/scriptlets/prevent-fetch.js | 3 ++ src/scriptlets/trusted-replace-node-text.js | 29 ++------------- tests/api/index.spec.js | 6 ++-- tests/scriptlets/prevent-adfly.test.js | 18 ---------- .../trusted-replace-node-text.test.js | 35 ------------------- wiki/compatibility-table.md | 10 ++---- 10 files changed, 15 insertions(+), 118 deletions(-) diff --git a/scripts/compatibility-table.json b/scripts/compatibility-table.json index dec9233b5..c73fb3c05 100644 --- a/scripts/compatibility-table.json +++ b/scripts/compatibility-table.json @@ -95,8 +95,7 @@ "abp": "log" }, { - "adg": "log-addEventListener", - "ubo": "addEventListener-logger.js (aell.js) (removed)" + "adg": "log-addEventListener" }, { "adg": "log-eval" @@ -145,8 +144,7 @@ "abp": "prevent-listener" }, { - "adg": "prevent-adfly", - "ubo": "adfly-defuser.js (removed)" + "adg": "prevent-adfly" }, { "adg": "prevent-bab" @@ -257,9 +255,6 @@ { "ubo": "alert-buster.js" }, - { - "ubo": "golem.de.js (removed)" - }, { "adg": "href-sanitizer", "ubo": "href-sanitizer.js" @@ -556,9 +551,6 @@ "adg": "set-popads-dummy", "ubo": "popads-dummy.js" }, - { - "ubo": "addthis_widget.js (removed)" - }, { "ubo": "amazon_ads.js" }, @@ -584,24 +576,12 @@ { "ubo": "hd-main.js" }, - { - "ubo": "ligatus_angular-tag.js (removed)" - }, - { - "ubo": "monkeybroker.js (removed)" - }, { "ubo": "outbrain-widget.js" }, - { - "ubo": "window.open-defuser.js (removed)" - }, { "ubo": "noeval.js" }, - { - "ubo": "mxpnl_mixpanel.js (removed)" - }, { "ubo": "noop-0.5s.mp3" } diff --git a/src/redirects/prevent-bab.js b/src/redirects/prevent-bab.js index 20ac99a9c..8b17267e0 100644 --- a/src/redirects/prevent-bab.js +++ b/src/redirects/prevent-bab.js @@ -21,6 +21,7 @@ import { preventBab as preventBabScriptlet } from '../scriptlets/prevent-bab'; * @added v1.3.19. */ const preventBab = preventBabScriptlet; + preventBab.names = [ 'prevent-bab', // list of prevent-bab redirect aliases diff --git a/src/scriptlets/prevent-adfly.js b/src/scriptlets/prevent-adfly.js index 952c9b4e3..8e80ce74a 100644 --- a/src/scriptlets/prevent-adfly.js +++ b/src/scriptlets/prevent-adfly.js @@ -90,10 +90,7 @@ export function preventAdfly(source) { preventAdfly.names = [ 'prevent-adfly', - // aliases are needed for matching the related scriptlet converted into our syntax - 'adfly-defuser.js', - 'ubo-adfly-defuser.js', - 'ubo-adfly-defuser', + // there are no aliases for this scriptlet ]; preventAdfly.injections = [ diff --git a/src/scriptlets/prevent-bab.js b/src/scriptlets/prevent-bab.js index 807f27686..78bf28cf9 100644 --- a/src/scriptlets/prevent-bab.js +++ b/src/scriptlets/prevent-bab.js @@ -97,7 +97,7 @@ export function preventBab(source) { preventBab.names = [ 'prevent-bab', - // there is no aliases for this scriptlet + // there are no aliases for this scriptlet ]; preventBab.injections = [hit]; diff --git a/src/scriptlets/prevent-fetch.js b/src/scriptlets/prevent-fetch.js index d75b2f536..b0baea350 100644 --- a/src/scriptlets/prevent-fetch.js +++ b/src/scriptlets/prevent-fetch.js @@ -222,6 +222,9 @@ export function preventFetch(source, propsToMatch, responseBody = 'emptyObj', re preventFetch.names = [ 'prevent-fetch', // aliases are needed for matching the related scriptlet converted into our syntax + 'prevent-fetch.js', + 'ubo-prevent-fetch.js', + 'ubo-prevent-fetch', 'no-fetch-if.js', 'ubo-no-fetch-if.js', 'ubo-no-fetch-if', diff --git a/src/scriptlets/trusted-replace-node-text.js b/src/scriptlets/trusted-replace-node-text.js index 8104814ef..25506cf47 100644 --- a/src/scriptlets/trusted-replace-node-text.js +++ b/src/scriptlets/trusted-replace-node-text.js @@ -85,33 +85,6 @@ import { */ /* eslint-enable max-len */ export function trustedReplaceNodeText(source, nodeName, textMatch, pattern, replacement, ...extraArgs) { - const uboAliases = [ - 'replace-node-text.js', - 'rpnt.js', - 'sed.js', - ]; - - /** - * UBO replaceNodeText scriptlet has different signature: - * function replaceNodeText(nodeName, pattern, replacement, ...extraArgs) {...} - * - * with extra params being passed as ['paramname', paramvalue] - */ - if (uboAliases.includes(source.name)) { - replacement = pattern; - pattern = textMatch; - // eslint-disable-next-line prefer-destructuring, prefer-rest-params - for (let i = 0; i < extraArgs.length; i += 1) { - const arg = extraArgs[i]; - if (arg === 'condition') { - textMatch = extraArgs[i + 1]; - break; - } - } - } - - const shouldLog = extraArgs.includes('verbose'); - const { selector, nodeNameMatch, @@ -119,6 +92,8 @@ export function trustedReplaceNodeText(source, nodeName, textMatch, pattern, rep patternMatch, } = parseNodeTextParams(nodeName, textMatch, pattern); + const shouldLog = extraArgs.includes('verbose'); + /** * Handles nodes by removing text content of matched nodes * diff --git a/tests/api/index.spec.js b/tests/api/index.spec.js index 8a50036da..6e89e1e28 100644 --- a/tests/api/index.spec.js +++ b/tests/api/index.spec.js @@ -293,8 +293,8 @@ describe('Test scriptlet api methods', () => { }, { // scriptlet with no parameters - actual: 'example.com#%#//scriptlet("prevent-adfly")', - expected: 'example.com##+js(adfly-defuser)', + actual: 'example.com#%#//scriptlet("prevent-fab-3.2.0")', + expected: 'example.com##+js(nofab)', }, { actual: 'example.org#@%#//scriptlet(\'prevent-setTimeout\', \'[native code]\', \'8000\')', @@ -310,7 +310,7 @@ describe('Test scriptlet api methods', () => { }, { actual: 'example.com#%#//scriptlet(\'prevent-fetch\', \'*\')', - expected: 'example.com##+js(no-fetch-if, /^/)', + expected: 'example.com##+js(prevent-fetch, /^/)', }, { actual: 'example.com#%#//scriptlet(\'close-window\')', diff --git a/tests/scriptlets/prevent-adfly.test.js b/tests/scriptlets/prevent-adfly.test.js index 061e81f20..17da03532 100644 --- a/tests/scriptlets/prevent-adfly.test.js +++ b/tests/scriptlets/prevent-adfly.test.js @@ -16,24 +16,6 @@ const afterEach = () => { module(name, { beforeEach, afterEach }); -test('Checking if alias name works', (assert) => { - const adgParams = { - name, - engine: 'test', - verbose: true, - }; - const uboParams = { - name: 'ubo-adfly-defuser.js', - engine: 'test', - verbose: true, - }; - - const codeByAdgParams = window.scriptlets.invoke(adgParams); - const codeByUboParams = window.scriptlets.invoke(uboParams); - - assert.strictEqual(codeByAdgParams, codeByUboParams, 'ubo name - ok'); -}); - test('ag works', (assert) => { assert.expect(2); const nativeDefineProperty = Object.defineProperty; diff --git a/tests/scriptlets/trusted-replace-node-text.test.js b/tests/scriptlets/trusted-replace-node-text.test.js index 73bbe6b62..2c83dc292 100644 --- a/tests/scriptlets/trusted-replace-node-text.test.js +++ b/tests/scriptlets/trusted-replace-node-text.test.js @@ -90,41 +90,6 @@ test('using matchers as regexes', (assert) => { }, 1); }); -test('arguments correctly reorganizing for ubo replace-node-text.js', (assert) => { - const done = assert.async(); - const uboAlias = 'rpnt.js'; - - const nodeName = 'div'; - const textMatch = 'content!'; - const pattern = 'content'; - const replacement = 'replaced'; - - const text = 'content!1'; - const expectedText = 'replaced!1'; - - const nodeBefore = addNode('div', text); - const safeNodeBefore = addNode('a', text); - - /** - * UBO replaceNodeText scriptlet has different signature: - * function replaceNodeText(nodeName, pattern, replacement, ...extraArgs) {...} - */ - runScriptlet(uboAlias, [nodeName, pattern, replacement, 'condition', textMatch]); - - const nodeAfter = addNode('div', text); - const safeNodeAfter = addNode('span', text); - setTimeout(() => { - assert.strictEqual(nodeAfter.textContent, expectedText, 'text content should be modified'); - assert.strictEqual(nodeBefore.textContent, expectedText, 'text content should be modified'); - - assert.strictEqual(safeNodeAfter.textContent, text, 'non-matched node should not be affected'); - assert.strictEqual(safeNodeBefore.textContent, text, 'non-matched node should not be affected'); - - assert.strictEqual(window.hit, 'FIRED', 'hit function should fire'); - done(); - }, 1); -}); - test('Log content', (assert) => { // There are 7 "asserts" in test but node is modified two times // so it's logged twice, that's why 9 is expected diff --git a/wiki/compatibility-table.md b/wiki/compatibility-table.md index 89c575d5a..e64746770 100644 --- a/wiki/compatibility-table.md +++ b/wiki/compatibility-table.md @@ -34,7 +34,7 @@ | [googletagservices-gpt](../wiki/about-scriptlets.md#googletagservices-gpt) | | | | [json-prune](../wiki/about-scriptlets.md#json-prune) | json-prune.js | json-prune | | [log](../wiki/about-scriptlets.md#log) | | log | -| [log-addEventListener](../wiki/about-scriptlets.md#log-addEventListener) | addEventListener-logger.js (aell.js) (removed) | | +| [log-addEventListener](../wiki/about-scriptlets.md#log-addEventListener) | | | | [log-eval](../wiki/about-scriptlets.md#log-eval) | | | | [log-on-stack-trace](../wiki/about-scriptlets.md#log-on-stack-trace) | | | | [m3u-prune](../wiki/about-scriptlets.md#m3u-prune) | m3u-prune.js | | @@ -49,7 +49,7 @@ | [pardot-1.0](../wiki/about-scriptlets.md#pardot-1.0) | | | | [prebid](../wiki/about-scriptlets.md#prebid) | | | | [prevent-addEventListener](../wiki/about-scriptlets.md#prevent-addEventListener) | addEventListener-defuser.js (aeld.js, prevent-addEventListener.js) | prevent-listener | -| [prevent-adfly](../wiki/about-scriptlets.md#prevent-adfly) | adfly-defuser.js (removed) | | +| [prevent-adfly](../wiki/about-scriptlets.md#prevent-adfly) | | | | [prevent-bab](../wiki/about-scriptlets.md#prevent-bab) | | | | [prevent-element-src-loading](../wiki/about-scriptlets.md#prevent-element-src-loading) | | | | [prevent-eval-if](../wiki/about-scriptlets.md#prevent-eval-if) | noeval-if.js (prevent-eval-if.js) | | @@ -79,7 +79,6 @@ | | webrtc-if.js | | | | overlay-buster.js | | | | alert-buster.js | | -| | golem.de.js (removed) | | | [href-sanitizer](../wiki/about-scriptlets.md#href-sanitizer) | href-sanitizer.js | | | | | abort-on-iframe-property-read | | | | abort-on-iframe-property-write | @@ -169,7 +168,6 @@ | [prevent-popads-net](../wiki/about-redirects.md#prevent-popads-net) | popads.js | | | [scorecardresearch-beacon](../wiki/about-redirects.md#scorecardresearch-beacon) | scorecardresearch_beacon.js | | | [set-popads-dummy](../wiki/about-redirects.md#set-popads-dummy) | popads-dummy.js | | -| | addthis_widget.js (removed) | | | | amazon_ads.js | | | | ampproject_v0.js | | | | chartbeat.js | | @@ -178,10 +176,6 @@ | | google-analytics_cx_api.js | | | | google-analytics_inpage_linkid.js | | | | hd-main.js | | -| | ligatus_angular-tag.js (removed) | | -| | monkeybroker.js (removed) | | | | outbrain-widget.js | | -| | window.open-defuser.js (removed) | | | | noeval.js | | -| | mxpnl_mixpanel.js (removed) | | | | noop-0.5s.mp3 | |