From 20dbb9da5692b5e15226d6bd5c5288b8cc183946 Mon Sep 17 00:00:00 2001 From: Slava Leleka Date: Wed, 21 Feb 2024 16:55:04 +0200 Subject: [PATCH] fix ubo-adg conversion of remove param --- CHANGELOG.md | 5 +++++ src/helpers/converter.ts | 4 ++++ tests/api/index.spec.js | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4ac2d227..7bd96506c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,12 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic - Validation of scriptlet rules with no name and args for multiple scriptlet exception rules [#377] +### Fixed + +- UBO→ADG conversion of `$remove$` scriptlet param [#404] + [Unreleased]: https://github.com/AdguardTeam/Scriptlets/compare/v1.10.1...HEAD +[#404]: https://github.com/AdguardTeam/Scriptlets/issues/404 [#377]: https://github.com/AdguardTeam/Scriptlets/issues/377 ## [v1.10.1] - 2024-02-12 diff --git a/src/helpers/converter.ts b/src/helpers/converter.ts index c7254881d..6ff0286fa 100644 --- a/src/helpers/converter.ts +++ b/src/helpers/converter.ts @@ -258,6 +258,10 @@ export const convertUboScriptletToAdg = (rule: string): string[] => { if (arg === '$') { outputArg = '$$'; } + // https://github.com/AdguardTeam/Scriptlets/issues/404 + if (arg === '$remove$') { + outputArg = '$$remove$$'; + } return outputArg; }) .map((arg) => wrapInSingleQuotes(arg)) diff --git a/tests/api/index.spec.js b/tests/api/index.spec.js index c4c1bff4d..52a4cddc4 100644 --- a/tests/api/index.spec.js +++ b/tests/api/index.spec.js @@ -220,6 +220,11 @@ describe('Test scriptlet api methods', () => { // eslint-disable-next-line max-len expected: "example.com#%#//scriptlet('ubo-spoof-css.js', '.adsbygoogle, #ads, .adTest', 'visibility', 'visible')", }, + // https://github.com/AdguardTeam/Scriptlets/issues/404 + { + actual: 'example.com##+js(set-local-storage-item, mode, $remove$)', + expected: "example.com#%#//scriptlet('ubo-set-local-storage-item.js', 'mode', '$remove$')", + }, ]; test.each(validTestCases)('$actual', ({ actual, expected }) => { expect(convertScriptletToAdg(actual)[0]).toStrictEqual(expected); @@ -351,6 +356,11 @@ describe('Test scriptlet api methods', () => { actual: "example.com#%#//scriptlet('set-cookie-reload', 'consent', 'true')", expected: 'example.com##+js(set-cookie-reload, consent, true)', }, + // https://github.com/AdguardTeam/Scriptlets/issues/404 + { + actual: "example.com#%#//scriptlet('set-local-storage-item', 'mode', '$remove$')", + expected: 'example.com##+js(set-local-storage-item, mode, $remove$)', + }, ]; test.each(testCases)('$actual', ({ actual, expected }) => { expect(convertAdgScriptletToUbo(actual)).toStrictEqual(expected);