Skip to content

Commit

Permalink
update compatibility table
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 30e994a
Merge: 13412ed c6b7eda
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu Jun 29 15:11:47 2023 +0300

    Merge branch 'master' into fix/compatibility-table-02

commit 13412ed
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu Jun 29 14:27:17 2023 +0300

    fix linter

commit ff8812b
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu Jun 29 14:19:02 2023 +0300

    update compatibility table

commit f988a53
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu Jun 29 14:18:48 2023 +0300

    fix script
  • Loading branch information
slavaleleka committed Jun 29, 2023
1 parent c6b7eda commit 7869e64
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 32 deletions.
41 changes: 25 additions & 16 deletions scripts/check-sources-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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;
}
}

Expand All @@ -202,7 +211,7 @@ async function getCurrentUBOScriptlets() {
}

let namesStr = name;
if (aliases) {
if (aliases.length > 0) {
namesStr += ` (${aliases.join(', ')})`;
}
names.push(namesStr);
Expand Down
16 changes: 8 additions & 8 deletions scripts/compatibility-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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)"
Expand Down
16 changes: 8 additions & 8 deletions wiki/compatibility-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | |
Expand Down Expand Up @@ -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) | |
Expand Down

0 comments on commit 7869e64

Please sign in to comment.