From 7869e64a38b41e6e9f0cf1b94642d40e953f5277 Mon Sep 17 00:00:00 2001 From: Slava Leleka Date: Thu, 29 Jun 2023 15:18:12 +0300 Subject: [PATCH] update compatibility table Squashed commit of the following: commit 30e994a7ae82b19b0f3ee5072c56a7fd9573a2cd Merge: 13412ed2 c6b7edac Author: Slava Leleka Date: Thu Jun 29 15:11:47 2023 +0300 Merge branch 'master' into fix/compatibility-table-02 commit 13412ed2742b7246cf83d617fbfed56e8a69de6a Author: Slava Leleka Date: Thu Jun 29 14:27:17 2023 +0300 fix linter commit ff8812b3f4712968afe66a5c781c9fe3ec8ae21b Author: Slava Leleka Date: Thu Jun 29 14:19:02 2023 +0300 update compatibility table commit f988a535960245ecc6bdb756c1d3eefc83139968 Author: Slava Leleka Date: Thu Jun 29 14:18:48 2023 +0300 fix script --- scripts/check-sources-updates.js | 41 +++++++++++++++++++------------- scripts/compatibility-table.json | 16 ++++++------- wiki/compatibility-table.md | 16 ++++++------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/scripts/check-sources-updates.js b/scripts/check-sources-updates.js index 1d4bbd5a..c1b16827 100644 --- a/scripts/check-sources-updates.js +++ b/scripts/check-sources-updates.js @@ -141,7 +141,8 @@ const COMMENT_MARKER = '//'; const FUNCTION_MARKER = 'function '; const NAME_MARKER_START = "name: '"; const NAME_MARKER_END = "',"; -const ALIASES_MARKER = 'aliases: '; +const ALIASES_MARKER_START = 'aliases: ['; +const ALIASES_MARKER_END = '],'; /** * Make request to UBO repo(master), parses and returns the list of UBO scriptlets @@ -164,14 +165,17 @@ async function getCurrentUBOScriptlets() { chunks.forEach((chunk) => { let name; - let aliases; + const aliases = []; const functionDefinitionIndex = chunk.indexOf(FUNCTION_MARKER) || chunk.length; const scriptletObjectText = chunk.slice(0, functionDefinitionIndex).trim(); + let areAliasesStarted = false; + const textLines = scriptletObjectText.split(EOL); for (let i = 0; i < textLines.length; i += 1) { const line = textLines[i].trim(); + if (line.startsWith(COMMENT_MARKER)) { continue; } @@ -181,19 +185,24 @@ async function getCurrentUBOScriptlets() { continue; } // parse the aliases - if (line.startsWith(ALIASES_MARKER)) { - const aliasesStr = line - .slice(ALIASES_MARKER.length) - // prepare the string for JSON.parse - .replace(/'/g, '"') - .replace(/,?$/, '') - // remove comments - // e.g. "[ 'rnt.js', 'sed.js' /* to be removed */ ]" - .replace(/\/\*[\s|\w]+?\*\//, ''); - aliases = JSON.parse(aliasesStr); - // 'name' string goes first and 'aliases' string goes after it - // so if aliases are parsed, no need to continue lines iterating - break; + if (line.startsWith(ALIASES_MARKER_START)) { + // now aliases array is set as multiline list + // so the flag is needed for correct parsing of following lines + areAliasesStarted = true; + continue; + } + if (areAliasesStarted) { + if (line === ALIASES_MARKER_END) { + areAliasesStarted = false; + // 'name' string goes first and 'aliases' string goes after it + // so if aliases are parsed, no need to continue lines iterating + break; + } + const alias = line + .replace(/,?$/g, '') + .replace(/'/g, ''); + aliases.push(alias); + continue; } } @@ -202,7 +211,7 @@ async function getCurrentUBOScriptlets() { } let namesStr = name; - if (aliases) { + if (aliases.length > 0) { namesStr += ` (${aliases.join(', ')})`; } names.push(namesStr); diff --git a/scripts/compatibility-table.json b/scripts/compatibility-table.json index b81bbab4..f5db7a90 100644 --- a/scripts/compatibility-table.json +++ b/scripts/compatibility-table.json @@ -86,7 +86,7 @@ }, { "adg": "prevent-addEventListener", - "ubo": "addEventListener-defuser.js (aeld.js)" + "ubo": "addEventListener-defuser.js (aeld.js, prevent-addEventListener.js)" }, { "adg": "prevent-adfly", @@ -97,18 +97,18 @@ }, { "adg": "prevent-eval-if", - "ubo": "noeval-if.js" + "ubo": "noeval-if.js (prevent-eval-if.js)" }, { "adg": "prevent-fab-3.2.0" }, { "adg": "prevent-fetch", - "ubo": "no-fetch-if.js" + "ubo": "no-fetch-if.js (prevent-fetch.js)" }, { "adg": "prevent-xhr", - "ubo": "no-xhr-if.js" + "ubo": "no-xhr-if.js (prevent-xhr.js)" }, { "adg": "prevent-popads-net" @@ -119,15 +119,15 @@ }, { "adg": "prevent-requestAnimationFrame", - "ubo": "no-requestAnimationFrame-if.js (norafif.js)" + "ubo": "no-requestAnimationFrame-if.js (norafif.js, prevent-requestAnimationFrame.js)" }, { "adg": "prevent-setInterval", - "ubo": "no-setInterval-if.js (nosiif.js)" + "ubo": "no-setInterval-if.js (nosiif.js, prevent-setInterval.js)" }, { "adg": "prevent-setTimeout", - "ubo": "no-setTimeout-if.js (nostif.js, setTimeout-defuser.js)" + "ubo": "no-setTimeout-if.js (nostif.js, prevent-setTimeout.js, setTimeout-defuser.js)" }, { "adg": "prevent-window-open" @@ -270,7 +270,7 @@ "ubo": "spoof-css.js" }, { - "ubo": "replace-node-text.js (rpnt.js, sed.js)" + "ubo": "replace-node-text.js (rpnt.js)" }, { "ubo": "trusted-set-constant.js (trusted-set.js)" diff --git a/wiki/compatibility-table.md b/wiki/compatibility-table.md index 6f95c41a..e12f3d1d 100644 --- a/wiki/compatibility-table.md +++ b/wiki/compatibility-table.md @@ -30,18 +30,18 @@ | [noeval](../wiki/about-scriptlets.md#noeval) | | | | [nowebrtc](../wiki/about-scriptlets.md#nowebrtc) | nowebrtc.js | | | [no-topics](../wiki/about-scriptlets.md#no-topics) | | | -| [prevent-addEventListener](../wiki/about-scriptlets.md#prevent-addEventListener) | addEventListener-defuser.js (aeld.js) | | +| [prevent-addEventListener](../wiki/about-scriptlets.md#prevent-addEventListener) | addEventListener-defuser.js (aeld.js, prevent-addEventListener.js) | | | [prevent-adfly](../wiki/about-scriptlets.md#prevent-adfly) | adfly-defuser.js | | | [prevent-bab](../wiki/about-scriptlets.md#prevent-bab) | | | -| [prevent-eval-if](../wiki/about-scriptlets.md#prevent-eval-if) | noeval-if.js | | +| [prevent-eval-if](../wiki/about-scriptlets.md#prevent-eval-if) | noeval-if.js (prevent-eval-if.js) | | | [prevent-fab-3.2.0](../wiki/about-scriptlets.md#prevent-fab-3.2.0) | | | -| [prevent-fetch](../wiki/about-scriptlets.md#prevent-fetch) | no-fetch-if.js | | -| [prevent-xhr](../wiki/about-scriptlets.md#prevent-xhr) | no-xhr-if.js | | +| [prevent-fetch](../wiki/about-scriptlets.md#prevent-fetch) | no-fetch-if.js (prevent-fetch.js) | | +| [prevent-xhr](../wiki/about-scriptlets.md#prevent-xhr) | no-xhr-if.js (prevent-xhr.js) | | | [prevent-popads-net](../wiki/about-scriptlets.md#prevent-popads-net) | | | | [prevent-refresh](../wiki/about-scriptlets.md#prevent-refresh) | refresh-defuser.js | | -| [prevent-requestAnimationFrame](../wiki/about-scriptlets.md#prevent-requestAnimationFrame) | no-requestAnimationFrame-if.js (norafif.js) | | -| [prevent-setInterval](../wiki/about-scriptlets.md#prevent-setInterval) | no-setInterval-if.js (nosiif.js) | | -| [prevent-setTimeout](../wiki/about-scriptlets.md#prevent-setTimeout) | no-setTimeout-if.js (nostif.js, setTimeout-defuser.js) | | +| [prevent-requestAnimationFrame](../wiki/about-scriptlets.md#prevent-requestAnimationFrame) | no-requestAnimationFrame-if.js (norafif.js, prevent-requestAnimationFrame.js) | | +| [prevent-setInterval](../wiki/about-scriptlets.md#prevent-setInterval) | no-setInterval-if.js (nosiif.js, prevent-setInterval.js) | | +| [prevent-setTimeout](../wiki/about-scriptlets.md#prevent-setTimeout) | no-setTimeout-if.js (nostif.js, prevent-setTimeout.js, setTimeout-defuser.js) | | | [prevent-window-open](../wiki/about-scriptlets.md#prevent-window-open) | | | | [remove-attr](../wiki/about-scriptlets.md#remove-attr) | remove-attr.js (ra.js) | | | [remove-class](../wiki/about-scriptlets.md#remove-class) | remove-class.js (rc.js) | | @@ -86,7 +86,7 @@ | | no-floc.js (removed) | | | | window.name-defuser.js | | | | spoof-css.js | | -| | replace-node-text.js (rpnt.js, sed.js) | | +| | replace-node-text.js (rpnt.js) | | | | trusted-set-constant.js (trusted-set.js) | | | | set-cookie.js | | | | no-window-open-if.js (nowoif.js) | |