Skip to content

Commit

Permalink
Merge branch 'release/v1.8' into feature/AG-16687
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamWr committed Jan 26, 2023
2 parents 602a502 + c179e6f commit 3ed6475
Show file tree
Hide file tree
Showing 226 changed files with 10,739 additions and 17,976 deletions.
23 changes: 0 additions & 23 deletions .eslintrc

This file was deleted.

48 changes: 48 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
extends: [
'airbnb-base',
'plugin:jsdoc/recommended',
],
parser: '@babel/eslint-parser',
parserOptions: {
babelOptions: {
rootMode: 'upward',
},
},
env: {
browser: true,
qunit: true,
},
rules: {
'max-len': [
'error',
{
code: 120,
ignoreUrls: true,
},
],
indent: ['error', 4, { SwitchCase: 1 }],
'no-param-reassign': 0,
'no-shadow': 0,
'import/prefer-default-export': 0,
'arrow-body-style': 0,
'import/no-extraneous-dependencies': 0,
'no-await-in-loop': 0,
'no-restricted-syntax': 0,
// jsdoc rules
'jsdoc/check-tag-names': ['error', { definedTags: ['scriptlet', 'trustedScriptlet', 'redirect'] }],
'jsdoc/require-jsdoc': 0,
'jsdoc/require-param': 0,
'jsdoc/valid-types': 0,
'jsdoc/no-undefined-types': 0,
'jsdoc/require-param-description': 0,
'jsdoc/require-returns-description': 0,
},
settings: {
jsdoc: {
preferredTypes: {
object: 'Object',
},
},
},
};
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
yarn test
107 changes: 85 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,91 @@
# Scriptlets and Redirect Resources Changelog

## v1.8.1

### Added
- new `trusted-set-constant` scriptlet [#137](https://github.com/AdguardTeam/Scriptlets/issues/137)
- new `inject-css-in-shadow-dom` scriptlet [#267](https://github.com/AdguardTeam/Scriptlets/issues/267)
- `throwFunc` and `noopCallbackFunc` prop values for `set-constant` scriptlet
- `recreateIframeForSlot` method mock to `googletagservices-gpt` redirect [#259](https://github.com/AdguardTeam/Scriptlets/issues/259)

### Changed

- add decimal delay matching for `prevent-setInterval` and `prevent-setTimeout` [#247](https://github.com/AdguardTeam/Scriptlets/issues/247)
- debug logging to include rule text when available
- `getScriptletFunction` calls to throw error on unknown scriptlet names

### Fixed

- `prevent-xhr` and `trusted-replace-xhr-response` closure bug on multiple requests [#261](https://github.com/AdguardTeam/Scriptlets/issues/261)
- missing `googletagmanager-gtm` in compatibility table

## v1.7.20

### Added

- `isBlocking()` method for Redirects class
- `file` field for redirect type

### Fixed

- Redirects types.

## v1.7.19

### Fixed

- `prevent-addEventListener` and `log-addEventListener` loosing context when encountering already bound `.addEventListener`
- `google-ima3` conversion

## v1.7.14

### Added

* `set-constant` ADG→UBO conversion for [`emptyArr` and `emptyObj`](https://github.com/uBlockOrigin/uBlock-issues/issues/2411)


## v1.7.13

### Fixed

* `isEmptyObject` helper not counting `prototype` as an object property

## v1.7.10

### Added

- new scriptlet `trusted-set-cookie-reload`

### Fixed

- `set-cookie-reload` infinite page reloading [#265](https://github.com/AdguardTeam/Scriptlets/issues/265)
- breakage of `prevent-element-src-loading` due to `window` getting into `apply` wrapper [#264](https://github.com/AdguardTeam/Scriptlets/issues/264)
- spread of args bug at `getXhrData` call for `trusted-replace-xhr-response`
- request properties array not being served to `getRequestData` and `parseMatchProps` helpers

## v1.7.3

### Added

* [Trusted scriptlets](./README.md#trusted-scriptlets) with extended capabilities:
* trusted-click-element [#23](https://github.com/AdguardTeam/Scriptlets/issues/23)
* trusted-replace-xhr-response [#202](https://github.com/AdguardTeam/Scriptlets/issues/202)
* trusted-replace-fetch-response
* trusted-set-local-storage-item
* trusted-set-cookie

* Scriptlets:
* xml-prune [#249](https://github.com/AdguardTeam/Scriptlets/issues/249)

### Improved

* Scriptlets:
* prevent-element-src-loading [#228](https://github.com/AdguardTeam/Scriptlets/issues/228)
* prevent-fetch [#216](https://github.com/AdguardTeam/Scriptlets/issues/216)
* abort-on-stack-trace [#201](https://github.com/AdguardTeam/Scriptlets/issues/201)
* abort-current-inline-script [#251](https://github.com/AdguardTeam/Scriptlets/issues/251)
* set-cookie & set-cookie-reload
* Redirects:
* google-ima3 [#255](https://github.com/AdguardTeam/Scriptlets/issues/255)
* metrika-yandex-tag [#254](https://github.com/AdguardTeam/Scriptlets/issues/254)
* googlesyndication-adsbygoogle [#252](https://github.com/AdguardTeam/Scriptlets/issues/252)
- [Trusted scriptlets](./README.md#trusted-scriptlets) with extended capabilities:
- `trusted-click-element` [#23](https://github.com/AdguardTeam/Scriptlets/issues/23)
- `trusted-replace-xhr-response` [#202](https://github.com/AdguardTeam/Scriptlets/issues/202)
- `trusted-replace-fetch-response`
- `trusted-set-local-storage-item`
- `trusted-set-cookie`

- Scriptlets:
- `xml-prune` [#249](https://github.com/AdguardTeam/Scriptlets/issues/249)

### Changed

- Scriptlets:
- `prevent-element-src-loading` [#228](https://github.com/AdguardTeam/Scriptlets/issues/228)
- `prevent-fetch` [#216](https://github.com/AdguardTeam/Scriptlets/issues/216)
- `abort-on-stack-trace` [#201](https://github.com/AdguardTeam/Scriptlets/issues/201)
- `abort-current-inline-script` [#251](https://github.com/AdguardTeam/Scriptlets/issues/251)
- `set-cookie` & `set-cookie-reload`
- Redirects:
- `google-ima3` [#255](https://github.com/AdguardTeam/Scriptlets/issues/255)
- `metrika-yandex-tag` [#254](https://github.com/AdguardTeam/Scriptlets/issues/254)
- `googlesyndication-adsbygoogle` [#252](https://github.com/AdguardTeam/Scriptlets/issues/252)
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AdGuard Scriptlets and Redirect resources
# AdGuard Scriptlets and Redirect Resources

AdGuard's Scriptlets and Redirect resources library which provides extended capabilities for content blocking.

Expand Down Expand Up @@ -161,9 +161,10 @@ And also there is a module at `dist/scriptlets.js` which has been exported to a

```javascript
/**
* Returns scriptlet code
* Returns scriptlet code by param
* @param {Source} source
* @returns {string}
* @returns {string|null} scriptlet code
* @throws on unknown scriptlet name
*/
scriptlets.invoke(source);
```
Expand Down Expand Up @@ -426,6 +427,11 @@ const redirects = new Redirects(rawYaml)
*/
const redirect = redirect.getRedirect('noopjs');

/**
* Check if redirect is blocking, e.g. click2load.html
*/
const isBlocking = redirect.isBlocking('click2load.html');

/**
* Redirect - object with following props
* {
Expand Down Expand Up @@ -509,9 +515,14 @@ There are two scripts to update wiki:
2. `yarn wiki:build-docs` — updates wiki pages `about-scriptlets.md` and `about-redirects.md`. They are being generated from JSDoc-type comments of corresponding scriptlets and redirects source files due to `@scriptlet`/`@redirect` and `@description` tags. Runs automatically while the release build.

## <a id="browser-compatibility"> Browser Compatibility
| Chrome | Edge | Firefox | IE | Opera | Safari |
| ------ | ---- | ------- | --- | ----- | ------ |
| 55 | 15 | 52 | 11 | 42 | 10 |
| Browser | Version |
|-----------------------|:----------|
| Chrome | ✅ 55 |
| Firefox | ✅ 52 |
| Edge | ✅ 15 |
| Opera | ✅ 42 |
| Safari | ✅ 11 |
| Internet Explorer ||

## <a id="used-by"> Projects using Scriptlets
* [CoreLibs](https://github.com/AdguardTeam/CoreLibs) (updates automatically)
Expand Down
24 changes: 19 additions & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,31 @@ module.exports = (api) => {
const config = {
presets: [
[
'@babel/env',
'@babel/preset-env',
{
exclude: ['transform-typeof-symbol'],
exclude: [
'@babel/plugin-transform-async-to-generator',
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-typeof-symbol',
'@babel/plugin-transform-computed-properties',
],
targets: [
'last 1 version',
'> 1%',
// ie 11 is dead and no longer supported
'not dead',
'chrome >= 55',
'firefox >= 52',
'edge >= 15',
'opera >= 42',
'safari >= 11',
],
},
],
],
plugins: [
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-private-methods',
'@babel/plugin-transform-arrow-functions',
],
};

Expand Down
2 changes: 1 addition & 1 deletion dist/build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.7.3
version=1.7.20
10 changes: 1 addition & 9 deletions dist/redirect-files/amazon-apstag.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
window.apstag = apstagWrapper;
hit(source);
}
function hit(source, message) {
function hit(source) {
if (source.verbose !== true) {
return;
}
Expand All @@ -33,14 +33,6 @@
var rulePart = source.ruleText.slice(ruleStartIndex);
prefix = "".concat(source.domainName).concat(rulePart);
}
var LOG_MARKER = "log: ";
if (message) {
if (message.indexOf(LOG_MARKER) === -1) {
log("".concat(prefix, " message:\n").concat(message));
} else {
log(message.slice(LOG_MARKER.length));
}
}
log("".concat(prefix, " trace start"));
if (trace) {
trace();
Expand Down
10 changes: 1 addition & 9 deletions dist/redirect-files/ati-smarttag.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
window.ATInternet = smartTagWrapper;
hit(source);
}
function hit(source, message) {
function hit(source) {
if (source.verbose !== true) {
return;
}
Expand All @@ -95,14 +95,6 @@
var rulePart = source.ruleText.slice(ruleStartIndex);
prefix = "".concat(source.domainName).concat(rulePart);
}
var LOG_MARKER = "log: ";
if (message) {
if (message.indexOf(LOG_MARKER) === -1) {
log("".concat(prefix, " message:\n").concat(message));
} else {
log(message.slice(LOG_MARKER.length));
}
}
log("".concat(prefix, " trace start"));
if (trace) {
trace();
Expand Down
10 changes: 1 addition & 9 deletions dist/redirect-files/didomi-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
}
hit(source);
}
function hit(source, message) {
function hit(source) {
if (source.verbose !== true) {
return;
}
Expand All @@ -132,14 +132,6 @@
var rulePart = source.ruleText.slice(ruleStartIndex);
prefix = "".concat(source.domainName).concat(rulePart);
}
var LOG_MARKER = "log: ";
if (message) {
if (message.indexOf(LOG_MARKER) === -1) {
log("".concat(prefix, " message:\n").concat(message));
} else {
log(message.slice(LOG_MARKER.length));
}
}
log("".concat(prefix, " trace start"));
if (trace) {
trace();
Expand Down
10 changes: 1 addition & 9 deletions dist/redirect-files/fingerprintjs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
window.Fingerprint2 = Fingerprint2;
hit(source);
}
function hit(source, message) {
function hit(source) {
if (source.verbose !== true) {
return;
}
Expand All @@ -41,14 +41,6 @@
var rulePart = source.ruleText.slice(ruleStartIndex);
prefix = "".concat(source.domainName).concat(rulePart);
}
var LOG_MARKER = "log: ";
if (message) {
if (message.indexOf(LOG_MARKER) === -1) {
log("".concat(prefix, " message:\n").concat(message));
} else {
log(message.slice(LOG_MARKER.length));
}
}
log("".concat(prefix, " trace start"));
if (trace) {
trace();
Expand Down
Loading

0 comments on commit 3ed6475

Please sign in to comment.