Skip to content

Commit e15e923

Browse files
committed
merge master, resolve conflicts
2 parents 10c0393 + 71d7683 commit e15e923

File tree

88 files changed

+334
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+334
-37
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = {
3737
'scriptlet',
3838
'trustedScriptlet',
3939
'redirect',
40+
'added',
4041
'jest-environment',
4142
],
4243
}],

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
<!-- TODO: add @added tag to the files with specific version -->
8+
<!-- during new scriptlets or redirects releasing -->
79

810
## [Unreleased]
911

1012
### Changed
1113

12-
- `trusted-set-cookie` and `trusted-set-cookie-reaload` scriptlets to not encode cookie name and value [#311](https://github.com/AdguardTeam/Scriptlets/issues/311)
13-
- improved `prevent-fetch` — if `responseType` is not specified,
14+
- `trusted-set-cookie` and `trusted-set-cookie-reload` scriptlets to not encode cookie name and value
15+
[#311](https://github.com/AdguardTeam/Scriptlets/issues/311)
16+
- improved `prevent-fetch`: if `responseType` is not specified,
1417
original response type is returned instead of `default` [#297](https://github.com/AdguardTeam/Scriptlets/issues/291)
1518

1619
### Fixed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adguard/scriptlets",
3-
"version": "1.9.13",
3+
"version": "1.9.14",
44
"description": "AdGuard's JavaScript library of Scriptlets and Redirect resources",
55
"scripts": {
66
"build": "babel-node bundler.js",

scripts/build-docs.js

+43-26
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,21 @@ const getMarkdownData = (dataItems) => {
102102
const output = dataItems.reduce((acc, {
103103
name,
104104
type,
105+
versionAdded,
105106
description,
106107
source,
107108
}) => {
108-
// low case name should be used as anchor
109+
// low case name should be used as an anchor in the table of content
109110
acc.list.push(`* [${name}](#${name.toLowerCase()})${EOL}`);
110111

111112
const typeOfSrc = type.toLowerCase().includes('scriptlet') ? 'Scriptlet' : 'Redirect';
112113

113-
// low case name should be used as anchor
114-
const body = `### <a id="${name.toLowerCase()}"></a> ⚡️ ${name}
114+
// 1. Low case name should be used as an anchor
115+
// 2. There is no EOL after 'version' string because `description` starts with `\n`
116+
const body = `### <a id="${name.toLowerCase()}"></a> ⚡️ ${name}${EOL}
117+
${versionAdded ? `> Added in ${versionAdded}` : '> Adding version is unknown.'}
115118
${description}${EOL}
116-
[${typeOfSrc} source](${source})
119+
[${typeOfSrc} source](${source})${EOL}
117120
* * *${EOL}${EOL}`;
118121
acc.body.push(body);
119122

@@ -135,18 +138,25 @@ const getMarkdownDataForStaticRedirects = () => {
135138
const staticRedirects = fs.readFileSync(path.resolve(__dirname, staticRedirectsPath), { encoding: 'utf8' });
136139
const parsedStaticRedirects = yaml.safeLoad(staticRedirects);
137140

138-
const output = parsedStaticRedirects.reduce((acc, { title, description }) => {
139-
if (description) {
140-
acc.list.push(`* [${title}](#${title})${EOL}`);
141+
const output = parsedStaticRedirects.reduce((acc, { title, description, added }) => {
142+
if (!title) {
143+
throw new Error('No title for static redirect');
144+
}
145+
if (!description) {
146+
throw new Error(`No description for static redirect '${title}'`);
147+
}
148+
if (!added) {
149+
throw new Error(`No added version for static redirect '${title}'`);
150+
}
151+
152+
acc.list.push(`* [${title}](#${title})${EOL}`);
141153

142-
const body = `### <a id="${title}"></a> ⚡️ ${title}
143-
${description}
144-
[Redirect source](${STATIC_REDIRECTS_RELATIVE_SOURCE})
154+
const body = `### <a id="${title}"></a> ⚡️ ${title}${EOL}
155+
${added ? `> Added in ${added}.` : '> Adding version is unknown.'}${EOL}
156+
${description}${EOL}
157+
[Redirect source](${STATIC_REDIRECTS_RELATIVE_SOURCE})${EOL}
145158
* * *${EOL}${EOL}`;
146-
acc.body.push(body);
147-
} else {
148-
throw new Error(`No description for ${title}`);
149-
}
159+
acc.body.push(body);
150160

151161
return acc;
152162
}, { list: [], body: [] });
@@ -170,18 +180,25 @@ const getMarkdownDataForBlockingRedirects = () => {
170180
const blockingRedirects = fs.readFileSync(blockingRedirectsPath, { encoding: 'utf8' });
171181
const parsedBlockingRedirects = yaml.safeLoad(blockingRedirects);
172182

173-
const output = parsedBlockingRedirects.reduce((acc, { title, description }) => {
174-
if (description) {
175-
acc.list.push(`* [${title}](#${title})${EOL}`);
183+
const output = parsedBlockingRedirects.reduce((acc, { title, description, added }) => {
184+
if (!title) {
185+
throw new Error('No title for blocking redirect');
186+
}
187+
if (!description) {
188+
throw new Error(`No description for blocking redirect '${title}'`);
189+
}
190+
if (!added) {
191+
throw new Error(`No added version for blocking redirect '${title}'`);
192+
}
193+
194+
acc.list.push(`* [${title}](#${title})${EOL}`);
176195

177-
const body = `### <a id="${title}"></a> ⚡️ ${title}
178-
${description}
179-
[Redirect source](${BLOCKING_REDIRECTS_RELATIVE_SOURCE}/${title})
196+
const body = `### <a id="${title}"></a> ⚡️ ${title}${EOL}
197+
${added ? `> Added in ${added}.` : '> Adding version is unknown.'}${EOL}
198+
${description}${EOL}
199+
[Redirect source](${BLOCKING_REDIRECTS_RELATIVE_SOURCE}/${title})${EOL}
180200
* * *${EOL}${EOL}`;
181-
acc.body.push(body);
182-
} else {
183-
throw new Error(`No description for ${title}`);
184-
}
201+
acc.body.push(body);
185202

186203
return acc;
187204
}, { list: [], body: [] });
@@ -206,8 +223,8 @@ const buildWikiAboutPages = () => {
206223
const staticRedirectsMarkdownData = getMarkdownDataForStaticRedirects();
207224
const blockingRedirectsMarkdownData = getMarkdownDataForBlockingRedirects();
208225

209-
const scriptletsPageContent = `## <a id="scriptlets"></a> Available Scriptlets
210-
${scriptletsMarkdownData.list}* * *
226+
const scriptletsPageContent = `## <a id="scriptlets"></a> Available Scriptlets${EOL}
227+
${scriptletsMarkdownData.list}* * *${EOL}
211228
${scriptletsMarkdownData.body}`;
212229
fs.writeFileSync(
213230
path.resolve(__dirname, aboutScriptletsPath),

scripts/helpers.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ const getFilesList = (relativeDirPath) => {
3232

3333
/**
3434
* @typedef {Object} CommentTag
35-
* @property {string} type tag name
36-
* @property {string} string text following the tag
35+
* @property {string} type Tag name, e.g. `@scriptlet`, `@redirect`, `@added`.
36+
* @property {string} string Text following the tag name.
3737
*/
3838

3939
/**
4040
* Returns parsed tags data which we use to describe the sources:
4141
* - `@scriptlet`/`trustedScriptlet`/`@redirect` to describe the type and name of source;
4242
* - `@description` actual description for scriptlet or redirect.
43-
* required comments from file.
43+
* - `@added` means version when scriptlet or redirect was implemented.
4444
* In one file might be comments describing scriptlet and redirect as well.
4545
*
4646
* @param {string} filePath absolute path to file
@@ -95,11 +95,17 @@ Please add one OR edit the list of NON_SCRIPTLETS_FILES / NON_REDIRECTS_FILES.`)
9595
* @returns {DescribingCommentData}
9696
*/
9797
const prepareCommentsData = (commentTags, source) => {
98-
const [base, sup] = commentTags;
98+
const [typeTag, descriptionTag, addedTag] = commentTags;
99+
const name = typeTag.string;
100+
const versionAdded = addedTag?.string;
101+
if (!versionAdded) {
102+
throw new Error(`No @added tag for ${name}`);
103+
}
99104
return {
100-
type: base.type,
101-
name: base.string,
102-
description: sup.string,
105+
type: typeTag.type,
106+
name,
107+
description: descriptionTag.string,
108+
versionAdded,
103109
source,
104110
};
105111
};

src/redirects/amazon-apstag.js

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { hit, noopFunc } from '../helpers/index';
22

33
/**
44
* @redirect amazon-apstag
5+
*
56
* @description
67
* Mocks Amazon's apstag.js
78
*
@@ -12,6 +13,8 @@ import { hit, noopFunc } from '../helpers/index';
1213
* ```
1314
* ||amazon-adsystem.com/aax2/apstag.js$script,redirect=amazon-apstag
1415
* ```
16+
*
17+
* @added v1.2.3.
1518
*/
1619
export function AmazonApstag(source) {
1720
const apstagWrapper = {

src/redirects/ati-smarttag.js

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { hit, noopFunc } from '../helpers/index';
22

33
/**
44
* @redirect ati-smarttag
5+
*
56
* @description
67
* Mocks AT Internat SmartTag.
78
* https://developers.atinternet-solutions.com/as2-tagging-en/javascript-en/getting-started-javascript-en/tracker-initialisation-javascript-en/
@@ -10,6 +11,8 @@ import { hit, noopFunc } from '../helpers/index';
1011
* ```
1112
* ||bloctel.gouv.fr/assets/scripts/smarttag.js$script,redirect=ati-smarttag
1213
* ```
14+
*
15+
* @added v1.5.0.
1316
*/
1417
export function ATInternetSmartTag(source) {
1518
const setNoopFuncWrapper = {

src/redirects/blocking-redirects.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
# use ">" if property contains long string
55

66
- title: click2load.html
7+
added: v1.5.0
78
description: |-
89
Redirects resource and replaces supposed content by decoy frame with button for original content recovering
910
1011
Related UBO redirect resource:
1112
https://github.com/gorhill/uBlock/blob/1.31.0/src/web_accessible_resources/click2load.html
1213
1314
**Example**
15+
1416
```
1517
||youtube.com/embed/$frame,third-party,redirect=click2load.html
1618
```

src/redirects/didomi-loader.js

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99

1010
/**
1111
* @redirect didomi-loader
12+
*
1213
* @description
1314
* Mocks Didomi's CMP loader script.
1415
* https://developers.didomi.io/
@@ -17,6 +18,8 @@ import {
1718
* ```
1819
* ||sdk.privacy-center.org/fbf86806f86e/loader.js$script,redirect=didomi-loader
1920
* ```
21+
*
22+
* @added v1.6.2.
2023
*/
2124
export function DidomiLoader(source) {
2225
function UserConsentStatusForVendorSubscribe() { }

src/redirects/fingerprintjs2.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { hit } from '../helpers/index';
33

44
/**
55
* @redirect fingerprintjs2
6+
*
67
* @description
78
* Mocks FingerprintJS v2
89
* https://github.com/fingerprintjs
@@ -14,6 +15,8 @@ import { hit } from '../helpers/index';
1415
* ```
1516
* ||the-japan-news.com/modules/js/lib/fgp/fingerprint2.js$script,redirect=fingerprintjs2
1617
* ```
18+
*
19+
* @added v1.5.0.
1720
*/
1821
export function Fingerprintjs2(source) {
1922
let browserId = '';

src/redirects/fingerprintjs3.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66

77
/**
88
* @redirect fingerprintjs3
9+
*
910
* @description
1011
* Mocks FingerprintJS v3
1112
* https://github.com/fingerprintjs
@@ -17,6 +18,8 @@ import {
1718
* ```
1819
* ||sephora.com/js/ufe/isomorphic/thirdparty/fp.min.js$script,redirect=fingerprintjs3
1920
* ```
21+
*
22+
* @added v1.6.2.
2023
*/
2124
export function Fingerprintjs3(source) {
2225
const visitorId = (() => {

src/redirects/gemius.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { hit, noopFunc } from '../helpers/index';
33

44
/**
55
* @redirect gemius
6+
*
67
* @description
78
* Mocks Gemius Analytics.
89
* https://flowplayer.com/developers/plugins/gemius
@@ -11,6 +12,8 @@ import { hit, noopFunc } from '../helpers/index';
1112
* ```
1213
* ||gapt.hit.gemius.pl/gplayer.js$script,redirect=gemius
1314
* ```
15+
*
16+
* @added v1.5.0.
1417
*/
1518
export function Gemius(source) {
1619
const GemiusPlayer = function () {};

src/redirects/google-analytics-ga.js

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77

88
/**
99
* @redirect google-analytics-ga
10+
*
1011
* @description
1112
* Mocks old Google Analytics API.
1213
*
@@ -17,6 +18,8 @@ import {
1718
* ```
1819
* ||google-analytics.com/ga.js$script,redirect=google-analytics-ga
1920
* ```
21+
*
22+
* @added v1.0.10.
2023
*/
2124
export function GoogleAnalyticsGa(source) {
2225
// Gaq constructor

src/redirects/google-analytics.js

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77

88
/**
99
* @redirect google-analytics
10+
*
1011
* @description
1112
* Mocks Google's Analytics and Tag Manager APIs.
1213
* [Covers obsolete googletagmanager-gtm redirect functionality](https://github.com/AdguardTeam/Scriptlets/issues/127).
@@ -19,6 +20,8 @@ import {
1920
* ||google-analytics.com/analytics.js$script,redirect=google-analytics
2021
* ||googletagmanager.com/gtm.js$script,redirect=googletagmanager-gtm
2122
* ```
23+
*
24+
* @added v1.0.10.
2225
*/
2326
export function GoogleAnalytics(source) {
2427
// eslint-disable-next-line func-names

src/redirects/google-ima3.js

+3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import {
77

88
/**
99
* @redirect google-ima3
10+
*
1011
* @description
1112
* Mocks the IMA SDK of Google.
1213
*
1314
* **Example**
1415
* ```
1516
* ||imasdk.googleapis.com/js/sdkloader/ima3.js$script,redirect=google-ima3
1617
* ```
18+
*
19+
* @added v1.6.2.
1720
*/
1821

1922
export function GoogleIma3(source) {

src/redirects/googlesyndication-adsbygoogle.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { hit } from '../helpers/index';
33
/* eslint-disable max-len */
44
/**
55
* @redirect googlesyndication-adsbygoogle
6+
*
67
* @description
78
* Mocks Google AdSense API.
89
*
@@ -13,6 +14,8 @@ import { hit } from '../helpers/index';
1314
* ```
1415
* ||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,redirect=googlesyndication-adsbygoogle
1516
* ```
17+
*
18+
* @added v1.0.10.
1619
*/
1720
/* eslint-enable max-len */
1821
export function GoogleSyndicationAdsByGoogle(source) {

src/redirects/googletagservices-gpt.js

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111

1212
/**
1313
* @redirect googletagservices-gpt
14+
*
1415
* @description
1516
* Mocks Google Publisher Tag API.
1617
*
@@ -21,6 +22,8 @@ import {
2122
* ```
2223
* ||googletagservices.com/tag/js/gpt.js$script,redirect=googletagservices-gpt
2324
* ```
25+
*
26+
* @added v1.0.10.
2427
*/
2528
export function GoogleTagServicesGpt(source) {
2629
const slots = new Map();

0 commit comments

Comments
 (0)