Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Jan 16, 2023
2 parents 0f789e1 + b350a74 commit d09e5ef
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 77 deletions.
8 changes: 5 additions & 3 deletions scripts/build-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ const getMarkdownData = (dataItems) => {
description,
source,
}) => {
acc.list.push(`* [${name}](#${name})${EOL}`);
// low case name should be used as anchor
acc.list.push(`* [${name}](#${name.toLowerCase()})${EOL}`);

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

const body = `### <a id="${name}"></a> ⚡️ ${name}
// low case name should be used as anchor
const body = `### <a id="${name.toLowerCase()}"></a> ⚡️ ${name}
${description}${EOL}
[${typeOfSrc} source](${source})
* * *${EOL}${EOL}`;
Expand Down
14 changes: 8 additions & 6 deletions scripts/compatibility-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
{
"adg": "prevent-popads-net"
},
{
"adg": "prevent-refresh",
"ubo": "refresh-defuser.js"
},
{
"adg": "prevent-requestAnimationFrame",
"ubo": "no-requestAnimationFrame-if.js (norafif.js)"
Expand Down Expand Up @@ -144,6 +148,10 @@
{
"adg": "set-popads-dummy"
},
{
"adg": "xml-prune",
"ubo": "xml-prune.js"
},
{
"ubo": "webrtc-if.js"
},
Expand Down Expand Up @@ -231,18 +239,12 @@
{
"ubo": "abort-current-script.js (acs.js, abort-current-inline-script.js, acis.js)"
},
{
"ubo": "refresh-defuser.js"
},
{
"ubo": "no-floc.js"
},
{
"ubo": "window.name-defuser.js"
},
{
"ubo": "xml-prune.js"
},
{
"ubo": "m3u-prune.js"
}
Expand Down
13 changes: 7 additions & 6 deletions src/scriptlets/prevent-addEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@ import {
*
* **Examples**
* 1. Prevent all `click` listeners:
* ```
* ```
* example.org#%#//scriptlet('prevent-addEventListener', 'click')
* ```
* ```
*
2. Prevent 'click' listeners with the callback body containing `searchString`.
* ```
* ```
* example.org#%#//scriptlet('prevent-addEventListener', 'click', 'searchString')
* ```
* ```
*
* For instance, this listener will not be called:
* ```javascript
*
* ```javascript
* el.addEventListener('click', () => {
* window.test = 'searchString';
* });
* ```
* ```
*/
/* eslint-enable max-len */
export function preventAddEventListener(source, typeSearch, listenerSearch) {
Expand Down
22 changes: 11 additions & 11 deletions src/scriptlets/prevent-window-open.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,36 @@ import {
*
* **Examples**
* 1. Prevent all `window.open` calls:
* ```
* ```
* example.org#%#//scriptlet('prevent-window-open')
* ```
* ```
*
* 2. Prevent `window.open` for all URLs containing `example`:
* ```
* ```
* example.org#%#//scriptlet('prevent-window-open', 'example')
* ```
* ```
*
* 3. Prevent `window.open` for all URLs matching RegExp `/example\./`:
* ```
* ```
* example.org#%#//scriptlet('prevent-window-open', '/example\./')
* ```
* ```
*
* 4. Prevent `window.open` for all URLs **NOT** containing `example`:
* ```
* ```
* example.org#%#//scriptlet('prevent-window-open', '!example')
* ```
*
* ```
*P
* Old syntax of prevent-window-open parameters:
* - `match` - optional, defaults to "matching", any positive number or nothing for "matching", 0 or empty string for "not matching"
* - `search` - optional, string or regexp for matching the URL passed to `window.open` call; defaults to search all `window.open` call
* - `replacement` - optional, string to return prop value or property instead of window.open; defaults to return noopFunc.
* **Examples**
* ```
* ```
* example.org#%#//scriptlet('prevent-window-open', '1', '/example\./')
* example.org#%#//scriptlet('prevent-window-open', '0', 'example')
* example.org#%#//scriptlet('prevent-window-open', '', '', 'trueFunc')
* example.org#%#//scriptlet('prevent-window-open', '1', '', '{propName=noopFunc}')
* ```
* ```
*
* > For better compatibility with uBO, old syntax is not recommended to use.
*/
Expand Down
13 changes: 7 additions & 6 deletions src/scriptlets/remove-cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ import { hit, toRegExp } from '../helpers/index';
*
* **Examples**
* 1. Removes all cookies:
* ```
* ```
* example.org#%#//scriptlet('remove-cookie')
* ```
* ```
*
* 2. Removes cookies which name contains `example` string.
* ```
* 2. Removes cookies which name contains `example` string:
* ```
* example.org#%#//scriptlet('remove-cookie', 'example')
* ```
* ```
*
* For instance this cookie will be removed:
*
* For instance this cookie will be removed
* ```javascript
* document.cookie = '__example=randomValue';
* ```
Expand Down
1 change: 1 addition & 0 deletions src/scriptlets/trusted-click-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
* - `cookie` - test string or regex against cookies on a page
* - `localStorage` - check if localStorage item is present
* - 'delay' - optional, time in ms to delay scriptlet execution, defaults to instant execution.
*
* **Examples**
* 1. Click single element by selector
* ```
Expand Down
76 changes: 39 additions & 37 deletions wiki/about-scriptlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* [abort-on-property-read](#abort-on-property-read)
* [abort-on-property-write](#abort-on-property-write)
* [abort-on-stack-trace](#abort-on-stack-trace)
* [adjust-setInterval](#adjust-setInterval)
* [adjust-setTimeout](#adjust-setTimeout)
* [adjust-setInterval](#adjust-setinterval)
* [adjust-setTimeout](#adjust-settimeout)
* [close-window](#close-window)
* [debug-current-inline-script](#debug-current-inline-script)
* [debug-on-property-read](#debug-on-property-read)
Expand All @@ -13,14 +13,14 @@
* [disable-newtab-links](#disable-newtab-links)
* [hide-in-shadow-dom](#hide-in-shadow-dom)
* [json-prune](#json-prune)
* [log-addEventListener](#log-addEventListener)
* [log-addEventListener](#log-addeventlistener)
* [log-eval](#log-eval)
* [log-on-stack-trace](#log-on-stack-trace)
* [log](#log)
* [no-topics](#no-topics)
* [noeval](#noeval)
* [nowebrtc](#nowebrtc)
* [prevent-addEventListener](#prevent-addEventListener)
* [prevent-addEventListener](#prevent-addeventlistener)
* [prevent-adfly](#prevent-adfly)
* [prevent-bab](#prevent-bab)
* [prevent-element-src-loading](#prevent-element-src-loading)
Expand All @@ -29,9 +29,9 @@
* [prevent-fetch](#prevent-fetch)
* [prevent-popads-net](#prevent-popads-net)
* [prevent-refresh](#prevent-refresh)
* [prevent-requestAnimationFrame](#prevent-requestAnimationFrame)
* [prevent-setInterval](#prevent-setInterval)
* [prevent-setTimeout](#prevent-setTimeout)
* [prevent-requestAnimationFrame](#prevent-requestanimationframe)
* [prevent-setInterval](#prevent-setinterval)
* [prevent-setTimeout](#prevent-settimeout)
* [prevent-window-open](#prevent-window-open)
* [prevent-xhr](#prevent-xhr)
* [remove-attr](#remove-attr)
Expand Down Expand Up @@ -205,7 +205,7 @@ example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'injectedScript')
[Scriptlet source](../src/scriptlets/abort-on-stack-trace.js)
* * *
### <a id="adjust-setInterval"></a> ⚡️ adjust-setInterval
### <a id="adjust-setinterval"></a> ⚡️ adjust-setInterval
Adjusts delay for specified setInterval() callbacks.
Expand Down Expand Up @@ -254,7 +254,7 @@ defaults to match all callbacks; invalid regular expression will cause exit and
[Scriptlet source](../src/scriptlets/adjust-setInterval.js)
* * *

### <a id="adjust-setTimeout"></a> ⚡️ adjust-setTimeout
### <a id="adjust-settimeout"></a> ⚡️ adjust-setTimeout

Adjusts delay for specified setTimeout() callbacks.

Expand Down Expand Up @@ -523,7 +523,7 @@ e.g. 'ad.*.src' instead of 'ad.0.src ad.1.src ad.2.src ...'
[Scriptlet source](../src/scriptlets/json-prune.js)
* * *

### <a id="log-addEventListener"></a> ⚡️ log-addEventListener
### <a id="log-addeventlistener"></a> ⚡️ log-addEventListener

Logs all addEventListener calls to the console.

Expand Down Expand Up @@ -627,7 +627,7 @@ example.org#%#//scriptlet('nowebrtc')
[Scriptlet source](../src/scriptlets/nowebrtc.js)
* * *
### <a id="prevent-addEventListener"></a> ⚡️ prevent-addEventListener
### <a id="prevent-addeventlistener"></a> ⚡️ prevent-addEventListener
Prevents adding event listeners for the specified events and callbacks.
Expand All @@ -646,21 +646,22 @@ defaults to match all listeners; invalid regular expression will cause exit and
**Examples**
1. Prevent all `click` listeners:
```
```
example.org#%#//scriptlet('prevent-addEventListener', 'click')
```
```

2. Prevent 'click' listeners with the callback body containing `searchString`.
```
```
example.org#%#//scriptlet('prevent-addEventListener', 'click', 'searchString')
```
```

For instance, this listener will not be called:
```javascript

```javascript
el.addEventListener('click', () => {
window.test = 'searchString';
});
```
```

[Scriptlet source](../src/scriptlets/prevent-addEventListener.js)
* * *
Expand Down Expand Up @@ -877,7 +878,7 @@ example.org#%#//scriptlet('prevent-refresh'[, delay])
[Scriptlet source](../src/scriptlets/prevent-refresh.js)
* * *

### <a id="prevent-requestAnimationFrame"></a> ⚡️ prevent-requestAnimationFrame
### <a id="prevent-requestanimationframe"></a> ⚡️ prevent-requestAnimationFrame

Prevents a `requestAnimationFrame` call
if the text of the callback is matching the specified search string which does not start with `!`;
Expand Down Expand Up @@ -945,7 +946,7 @@ So do not use the scriptlet without any parameter in production filter lists.
[Scriptlet source](../src/scriptlets/prevent-requestAnimationFrame.js)
* * *
### <a id="prevent-setInterval"></a> ⚡️ prevent-setInterval
### <a id="prevent-setinterval"></a> ⚡️ prevent-setInterval
Prevents a `setInterval` call if:
1) the text of the callback is matching the specified `matchCallback` string/regexp which does not start with `!`;
Expand Down Expand Up @@ -1047,7 +1048,7 @@ and obviously it can not be matched by `matchCallback`.
[Scriptlet source](../src/scriptlets/prevent-setInterval.js)
* * *
### <a id="prevent-setTimeout"></a> ⚡️ prevent-setTimeout
### <a id="prevent-settimeout"></a> ⚡️ prevent-setTimeout
Prevents a `setTimeout` call if:
1) the text of the callback is matching the specified `matchCallback` string/regexp which does not start with `!`;
Expand Down Expand Up @@ -1174,36 +1175,36 @@ for accessing its methods (blur(), focus() etc.) and will be removed after the d
**Examples**
1. Prevent all `window.open` calls:
```
```
example.org#%#//scriptlet('prevent-window-open')
```
```
2. Prevent `window.open` for all URLs containing `example`:
```
```
example.org#%#//scriptlet('prevent-window-open', 'example')
```
```
3. Prevent `window.open` for all URLs matching RegExp `/example\./`:
```
```
example.org#%#//scriptlet('prevent-window-open', '/example\./')
```
```
4. Prevent `window.open` for all URLs **NOT** containing `example`:
```
```
example.org#%#//scriptlet('prevent-window-open', '!example')
```
```
P
Old syntax of prevent-window-open parameters:
- `match` - optional, defaults to "matching", any positive number or nothing for "matching", 0 or empty string for "not matching"
- `search` - optional, string or regexp for matching the URL passed to `window.open` call; defaults to search all `window.open` call
- `replacement` - optional, string to return prop value or property instead of window.open; defaults to return noopFunc.
**Examples**
```
```
example.org#%#//scriptlet('prevent-window-open', '1', '/example\./')
example.org#%#//scriptlet('prevent-window-open', '0', 'example')
example.org#%#//scriptlet('prevent-window-open', '', '', 'trueFunc')
example.org#%#//scriptlet('prevent-window-open', '1', '', '{propName=noopFunc}')
```
```
> For better compatibility with uBO, old syntax is not recommended to use.
Expand Down Expand Up @@ -1416,16 +1417,17 @@ example.org#%#//scriptlet('remove-cookie'[, match])
**Examples**
1. Removes all cookies:
```
```
example.org#%#//scriptlet('remove-cookie')
```
```
2. Removes cookies which name contains `example` string.
```
2. Removes cookies which name contains `example` string:
```
example.org#%#//scriptlet('remove-cookie', 'example')
```
```
For instance this cookie will be removed:
For instance this cookie will be removed
```javascript
document.cookie = '__example=randomValue';
```
Expand Down
Loading

0 comments on commit d09e5ef

Please sign in to comment.