diff --git a/package.json b/package.json index f6fc46f9..f3a9b0a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "adguard-filters-compiler", - "version": "1.0.42", + "version": "1.0.43", "description": "Adguard filters compiler", "homepage": "http://adguard.com", "dependencies": { diff --git a/src/main/converter.js b/src/main/converter.js index db182137..22569ebc 100644 --- a/src/main/converter.js +++ b/src/main/converter.js @@ -131,14 +131,15 @@ module.exports = (() => { } // Convert UBO and ABP scriptlets to AdGuard scriptlets - if (!rule.startsWith('!') && !rule.startsWith('#') && (scriptlets.isUboScriptletRule(rule) || scriptlets.isAbpSnippetRule(rule))) { + if (!rule.startsWith(RuleMasks.MASK_COMMENT) && (scriptlets.isUboScriptletRule(rule) || scriptlets.isAbpSnippetRule(rule))) { const convertedRule = scriptlets.convertScriptletToAdg(rule); if (!convertedRule) { logger.error(`Unable to convert scriptlet to Adguard syntax: "${rule}" `); rule = `! Inconvertible scriptlet: ${rule}`; } else { logger.log(`Rule "${rule}" converted to: ${convertedRule}`); - rule = convertedRule; + result.push(...convertedRule); + continue; } } diff --git a/src/test/test-converter.js b/src/test/test-converter.js index fdf909b6..3b013849 100644 --- a/src/test/test-converter.js +++ b/src/test/test-converter.js @@ -178,6 +178,13 @@ QUnit.test('Test scriptlets lib converter', (assert) => { actual = scriptlets.convertScriptletToAdg('test.com#$#abort-on-property-read adsShown'); expected = 'test.com#%#//scriptlet("abp-abort-on-property-read", "adsShown")'; assert.equal(actual, expected); + + actual = scriptlets.convertScriptletToAdg('example.org#$#hide-if-has-and-matches-style \'d[id^="_"]\' \'div > s\' \'display: none\'; hide-if-contains /.*/ .p \'a[href^="/ad__c?"]\''); + expected = [ + 'example.org#%#//scriptlet("abp-hide-if-has-and-matches-style", "d[id^=\\"_\\"]", "div > s", "display: none")', + 'example.org#%#//scriptlet("abp-hide-if-contains", "/.*/", ".p", "a[href^=\\"/ad__c?\\"]")', + ]; + assert.deepEqual(actual, expected); }); QUnit.test('Test UBO to Adguard scriptlet converter', (assert) => {