Skip to content

Commit

Permalink
Merge branch 'feature/md-lint' of ssh://bit.adguard.com:7999/adguard-…
Browse files Browse the repository at this point in the history
…filters/scriptlets into feature/md-lint
  • Loading branch information
slavaleleka committed May 25, 2023
2 parents c7824f7 + 5573145 commit afb4d9a
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 53 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ if ([[ `git diff --cached --name-only --diff-filter=ACM` == *"dist/"* ]] && [[ !
fi

yarn lint-staged
yarn lint:md
yarn test
3 changes: 2 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"no-multiple-blanks": { "maximum": 2 },
"no-inline-html": { "allowed_elements": ["a"]},
"no-duplicate-header": { "siblings_only": true },
"no-blanks-blockquote": false
"no-blanks-blockquote": false,
"ul-style": { "style": "dash" }
}
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- ability for `prevent-element-src-loading` scriptlet to prevent inline `onerror` and match `link` tag [#276](https://github.com/AdguardTeam/Scriptlets/issues/276)
- ability for `prevent-element-src-loading` scriptlet to prevent inline `onerror`
and match `link` tag [#276](https://github.com/AdguardTeam/Scriptlets/issues/276)
- new special value modifiers for `set-constant` [#316](https://github.com/AdguardTeam/Scriptlets/issues/316)

### Changed
Expand Down
100 changes: 50 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

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

* [Scriptlets](#scriptlets)
* [Syntax](#scriptlet-syntax)
* [Available scriptlets](./wiki/about-scriptlets.md#scriptlets)
* [Scriptlets compatibility table](./wiki/compatibility-table.md#scriptlets)
* [Trusted scriptlets](#trusted-scriptlets)
* [Restriction](#trusted-scriptlets-restriction)
* [Available trusted scriptlets](./wiki/about-trusted-scriptlets.md#trusted-scriptlets)
* [Redirect resources](#redirect-resources)
* [Syntax](#redirect-syntax)
* [Available redirect resources](./wiki/about-redirects.md#redirect-resources)
* [Redirect resources compatibility table](./wiki/compatibility-table.md#redirects)
* [How to build](#how-to-build)
* [How to test](#how-to-test)
* [How to update wiki](#how-to-update-wiki)
* [Browser compatibility](#browser-compatibility)
* [Projects using Scriptlets](#used-by)
- [Scriptlets](#scriptlets)
- [Syntax](#scriptlet-syntax)
- [Available scriptlets](./wiki/about-scriptlets.md#scriptlets)
- [Scriptlets compatibility table](./wiki/compatibility-table.md#scriptlets)
- [Trusted scriptlets](#trusted-scriptlets)
- [Restriction](#trusted-scriptlets-restriction)
- [Available trusted scriptlets](./wiki/about-trusted-scriptlets.md#trusted-scriptlets)
- [Redirect resources](#redirect-resources)
- [Syntax](#redirect-syntax)
- [Available redirect resources](./wiki/about-redirects.md#redirect-resources)
- [Redirect resources compatibility table](./wiki/compatibility-table.md#redirects)
- [How to build](#how-to-build)
- [How to test](#how-to-test)
- [How to update wiki](#how-to-update-wiki)
- [Browser compatibility](#browser-compatibility)
- [Projects using Scriptlets](#used-by)

* * *

Expand All @@ -34,24 +34,24 @@ Please note, that in order to achieve cross-blocker compatibility, we also suppo
rule = [domains] "#%#//scriptlet(" scriptletName arguments ")"
```

* `scriptletName` (mandatory) is a name of the scriptlet from AdGuard's scriptlets library
* `arguments` (optional) a list of `String` arguments (no other types of arguments are supported)
- `scriptletName` (mandatory) is a name of the scriptlet from AdGuard's scriptlets library
- `arguments` (optional) a list of `String` arguments (no other types of arguments are supported)

> **Remarks**
>
> * The meaning of the arguments depends on the scriptlet.
> - The meaning of the arguments depends on the scriptlet.
>
> * Special characters in scriptlet argument must be escaped properly:
> * valid:
> * `'prop["nested"]'`
> * `"prop['nested']"`
> * `'prop[\'nested\']'`
> * `"prop[\"nested\"]"`
> * not valid:
> * `'prop['nested']'`
> * `"prop["nested"]"`
> - Special characters in scriptlet argument must be escaped properly:
> - valid:
> - `'prop["nested"]'`
> - `"prop['nested']"`
> - `'prop[\'nested\']'`
> - `"prop[\"nested\"]"`
> - not valid:
> - `'prop['nested']'`
> - `"prop["nested"]"`
>
> * You can use either single or double quotes for the scriptlet name and arguments.
> - You can use either single or double quotes for the scriptlet name and arguments.
> Single quote is recommended but not for cases when its usage makes readability worse,
> e.g. `".css('display','block');"` is more preferred then `'.css(\'display\',\'block\');'`.
Expand All @@ -66,8 +66,8 @@ example.org#%#//scriptlet('remove-class', 'branding', 'div[class^="inner"]')
This rule applies the `abort-on-property-read` scriptlet on all pages of `example.org` and its subdomains,
and passes one argument to it (`alert`).

* **[Scriptlets list](./wiki/about-scriptlets.md#scriptlets)**
* **[Scriptlets compatibility table](./wiki/compatibility-table.md#scriptlets)**
- **[Scriptlets list](./wiki/about-scriptlets.md#scriptlets)**
- **[Scriptlets compatibility table](./wiki/compatibility-table.md#scriptlets)**


### <a id="trusted-scriptlets"></a> Trusted scriptlets
Expand All @@ -81,9 +81,9 @@ to be easily distinguished from common scriptlets.
Trusted scriptlets application must be restricted due to dangerous nature of their capabilities.
Allowed sources of trusted scriptlets are:

* filters created by AdGuard Team,
* custom filters which were installed as `trusted`,
* user rules.
- filters created by AdGuard Team,
- custom filters which were installed as `trusted`,
- user rules.

> Trusted scriptlets has no compatibility table as they are not compatible with any other blocker.
Expand All @@ -107,12 +107,12 @@ so rules with this modifier support all other basic modifiers like `$domain`, `$
The value of the `$redirect` modifier must be the name of the resource that will be used for redirection.
See the list of [available redirect resources](./wiki/about-redirects.md#redirect-resources).

#### Examples
### Examples

* `||example.org/script.js$script,redirect=noopjs` — redirects all requests to `script.js`
to the resource named `noopjs`.
* `||example.org/test.mp4$media,redirect=noopmp4-1s` — requests to `example.org/test.mp4` will be redirected
to the resource named `noopmp4-1s`.
- `||example.org/script.js$script,redirect=noopjs` — redirects all requests to `script.js`
to the resource named `noopjs`.
- `||example.org/test.mp4$media,redirect=noopmp4-1s` — requests to `example.org/test.mp4` will be redirected
to the resource named `noopmp4-1s`.

> `$redirect` rules priority is higher than the regular basic blocking rules' priority.
> This means that if there's a basic blocking rule (even with `$important` modifier),
Expand All @@ -123,8 +123,8 @@ See the list of [available redirect resources](./wiki/about-redirects.md#redirec
> uBlock Origin specifies additional resource name `none` that can disable other redirect rules.
> AdGuard does not support it, use `$badfilter` to disable specific rules.
* **[Redirect resources list](./wiki/about-redirects.md#redirect-resources)**
* **[Redirect resources compatibility table](./wiki/compatibility-table.md#redirects)**
- **[Redirect resources list](./wiki/about-redirects.md#redirect-resources)**
- **[Redirect resources compatibility table](./wiki/compatibility-table.md#redirects)**

* * *

Expand Down Expand Up @@ -618,12 +618,12 @@ There are two scripts to update wiki:

## <a id="used-by"> Projects using Scriptlets

* [CoreLibs](https://github.com/AdguardTeam/CoreLibs) (updates automatically)
* [TSUrlFilter](https://github.com/AdguardTeam/tsurlfilter)
* [FiltersCompiler](https://github.com/AdguardTeam/FiltersCompiler)
(`tsurlfilter`'s update might be required as well)
* [AdguardBrowserExtension](https://github.com/AdguardTeam/AdguardBrowserExtension)
(`tsurlfilter` also should be updated)
* [AdguardForSafari](https://github.com/AdguardTeam/AdGuardForSafari) (`adguard-resources` should be updated)
* [AdguardForiOS](https://github.com/AdguardTeam/AdguardForiOS)
(`tsurlfilter` should be updated in `advanced-adblocker-web-extension`)
- [CoreLibs](https://github.com/AdguardTeam/CoreLibs) (updates automatically)
- [TSUrlFilter](https://github.com/AdguardTeam/tsurlfilter)
- [FiltersCompiler](https://github.com/AdguardTeam/FiltersCompiler)
(`tsurlfilter`'s update might be required as well)
- [AdguardBrowserExtension](https://github.com/AdguardTeam/AdguardBrowserExtension)
(`tsurlfilter` also should be updated)
- [AdguardForSafari](https://github.com/AdguardTeam/AdGuardForSafari) (`adguard-resources` should be updated)
- [AdguardForiOS](https://github.com/AdguardTeam/AdguardForiOS)
(`tsurlfilter` should be updated in `advanced-adblocker-web-extension`)
8 changes: 8 additions & 0 deletions bamboo-specs/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ Build:
ls -alt
yarn install
# build docs
yarn wiki:build-docs
node ./scripts/build-compatibility-table.js
# lint code and docs
yarn lint
yarn test
yarn build
rm -rf node_modules
artifacts:
- name: scriptlets.corelibs.json
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"browserstack": "babel-node scripts/build-tests.js && node browserstack.js",
"gui-test": "babel-node scripts/build-tests.js && open http://localhost:8585 && node ./tests/server.js",
"jest": "jest trusted-set-cookie-reload.spec.js",
"lint": "eslint --cache . && markdownlint .",
"lint": "eslint --cache . && yarn lint:md",
"lint:md": "markdownlint .",
"lint-staged": "lint-staged",
"prepare": "husky install",
"wiki:build-table": "node ./scripts/check-sources-updates.js && node ./scripts/build-compatibility-table.js",
Expand Down

0 comments on commit afb4d9a

Please sign in to comment.