diff --git a/scripts/compatibility-table.json b/scripts/compatibility-table.json index ccce7b0f7..cd004bc7d 100644 --- a/scripts/compatibility-table.json +++ b/scripts/compatibility-table.json @@ -27,6 +27,10 @@ "adg": "adjust-setTimeout", "ubo": "adjust-setTimeout.js (nano-setTimeout-booster.js, nano-stb.js)" }, + { + "adg": "call-nothrow", + "ubo": "call-nothrow.js" + }, { "adg": "close-window", "ubo": "close-window.js (window-close-if.js)" @@ -168,7 +172,8 @@ "ubo": "set-cookie.js" }, { - "adg": "set-cookie-reload" + "adg": "set-cookie-reload", + "ubo": "set-cookie-reload.js" }, { "adg": "set-local-storage-item", @@ -181,6 +186,10 @@ "adg": "set-session-storage-item", "ubo": "set-session-storage-item.js" }, + { + "adg": "spoof-css", + "ubo": "spoof-css.js" + }, { "adg": "xml-prune", "ubo": "xml-prune.js" @@ -200,10 +209,6 @@ { "ubo": "href-sanitizer.js" }, - { - "adg": "call-nothrow", - "ubo": "call-nothrow.js" - }, { "abp": "abort-on-iframe-property-read" }, @@ -270,10 +275,6 @@ { "ubo": "window.name-defuser.js" }, - { - "adg": "spoof-css", - "ubo": "spoof-css.js" - }, { "ubo": "trusted-set-constant.js (trusted-set.js)" }, @@ -301,9 +302,6 @@ { "ubo": "prevent-canvas.js" }, - { - "ubo": "set-cookie-reload.js" - }, { "ubo": "trusted-set-cookie-reload.js" }, @@ -536,4 +534,4 @@ "ubo": "noop-0.5s.mp3" } ] -} \ No newline at end of file +} diff --git a/src/scriptlets/set-cookie-reload.js b/src/scriptlets/set-cookie-reload.js index cc7e4ab9a..3745c3ade 100644 --- a/src/scriptlets/set-cookie-reload.js +++ b/src/scriptlets/set-cookie-reload.js @@ -95,6 +95,10 @@ export function setCookieReload(source, name, value, path = '/') { setCookieReload.names = [ 'set-cookie-reload', + // aliases are needed for matching the related scriptlet converted into our syntax + 'set-cookie-reload.js', + 'ubo-set-cookie-reload.js', + 'ubo-set-cookie-reload', ]; setCookieReload.injections = [ diff --git a/tests/api/index.spec.js b/tests/api/index.spec.js index d38ca5902..ff2f1d7bf 100644 --- a/tests/api/index.spec.js +++ b/tests/api/index.spec.js @@ -183,6 +183,10 @@ describe('Test scriptlet api methods', () => { actual: 'example.com##+js(set-cookie, CookieConsent, true)', expected: "example.com#%#//scriptlet('ubo-set-cookie.js', 'CookieConsent', 'true')", }, + { + actual: 'example.com##+js(set-cookie-reload, isSet, 1)', + expected: "example.com#%#//scriptlet('ubo-set-cookie-reload.js', 'isSet', '1')", + }, { actual: 'example.com##+js(set-local-storage-item, gdpr_popup, true)', expected: "example.com#%#//scriptlet('ubo-set-local-storage-item.js', 'gdpr_popup', 'true')", @@ -326,6 +330,10 @@ describe('Test scriptlet api methods', () => { actual: "example.com#%#//scriptlet('spoof-css', '.adsbygoogle, #ads, .adTest', 'visibility', 'visible')", expected: 'example.com##+js(spoof-css, .adsbygoogle\\, #ads\\, .adTest, visibility, visible)', }, + { + actual: "example.com#%#//scriptlet('set-cookie-reload', 'consent', 'true')", + expected: 'example.com##+js(set-cookie-reload, consent, true)', + }, ]; test.each(testCases)('$actual', ({ actual, expected }) => { expect(convertAdgScriptletToUbo(actual)).toStrictEqual(expected); diff --git a/tests/scriptlets/set-cookie-reload.test.js b/tests/scriptlets/set-cookie-reload.test.js new file mode 100644 index 000000000..26deebed3 --- /dev/null +++ b/tests/scriptlets/set-cookie-reload.test.js @@ -0,0 +1,35 @@ +/* eslint-disable no-underscore-dangle */ +import { clearGlobalProps } from '../helpers'; + +const { test, module } = QUnit; +const name = 'set-cookie-reload'; + +const beforeEach = () => { + window.__debug = () => { + window.hit = 'FIRED'; + }; +}; + +const afterEach = () => { + clearGlobalProps('hit', '__debug'); +}; + +module(name, { beforeEach, afterEach }); + +test('Checking if alias name works', (assert) => { + const adgParams = { + name, + engine: 'test', + verbose: true, + }; + const uboParams = { + name: 'ubo-set-cookie-reload.js', + engine: 'test', + verbose: true, + }; + + const codeByAdgParams = window.scriptlets.invoke(adgParams); + const codeByUboParams = window.scriptlets.invoke(uboParams); + + assert.strictEqual(codeByAdgParams, codeByUboParams, 'ubo name - ok'); +}); diff --git a/wiki/compatibility-table.md b/wiki/compatibility-table.md index 0b7e9eb47..1d4bb5c6e 100644 --- a/wiki/compatibility-table.md +++ b/wiki/compatibility-table.md @@ -14,6 +14,7 @@ | [abort-on-stack-trace](../wiki/about-scriptlets.md#abort-on-stack-trace) | abort-on-stack-trace.js (aost.js) | | | [adjust-setInterval](../wiki/about-scriptlets.md#adjust-setInterval) | adjust-setInterval.js (nano-setInterval-booster.js, nano-sib.js) | | | [adjust-setTimeout](../wiki/about-scriptlets.md#adjust-setTimeout) | adjust-setTimeout.js (nano-setTimeout-booster.js, nano-stb.js) | | +| [call-nothrow](../wiki/about-scriptlets.md#call-nothrow) | call-nothrow.js | | | [close-window](../wiki/about-scriptlets.md#close-window) | close-window.js (window-close-if.js) | | | [debug-current-inline-script](../wiki/about-scriptlets.md#debug-current-inline-script) | | | | [debug-on-property-read](../wiki/about-scriptlets.md#debug-on-property-read) | | | @@ -51,17 +52,17 @@ | [set-attr](../wiki/about-scriptlets.md#set-attr) | set-attr.js | | | [set-constant](../wiki/about-scriptlets.md#set-constant) | set-constant.js (set.js) | override-property-read | | [set-cookie](../wiki/about-scriptlets.md#set-cookie) | set-cookie.js | | -| [set-cookie-reload](../wiki/about-scriptlets.md#set-cookie-reload) | | | +| [set-cookie-reload](../wiki/about-scriptlets.md#set-cookie-reload) | set-cookie-reload.js | | | [set-local-storage-item](../wiki/about-scriptlets.md#set-local-storage-item) | set-local-storage-item.js | | | [set-popads-dummy](../wiki/about-scriptlets.md#set-popads-dummy) | | | | [set-session-storage-item](../wiki/about-scriptlets.md#set-session-storage-item) | set-session-storage-item.js | | +| [spoof-css](../wiki/about-scriptlets.md#spoof-css) | spoof-css.js | | | [xml-prune](../wiki/about-scriptlets.md#xml-prune) | xml-prune.js | | | | webrtc-if.js | | | | overlay-buster.js | | | | alert-buster.js | | | | golem.de.js (removed) | | | | href-sanitizer.js | | -| [call-nothrow](../wiki/about-scriptlets.md#call-nothrow) | call-nothrow.js | | | | | abort-on-iframe-property-read | | | | abort-on-iframe-property-write | | | | freeze-element | @@ -84,7 +85,6 @@ | | | trace | | | | race | | | window.name-defuser.js | | -| [spoof-css](../wiki/about-scriptlets.md#spoof-css) | spoof-css.js | | | | trusted-set-constant.js (trusted-set.js) | | | | trusted-set-cookie.js | | | | trusted-set-local-storage-item.js | | @@ -94,7 +94,6 @@ | | trusted-replace-xhr-response.js | | | | multiup.js | | | | prevent-canvas.js | | -| | set-cookie-reload.js | | | | trusted-set-cookie-reload.js | | | | trusted-click-element.js | | | | trusted-prune-inbound-object.js | |