- Resources Library·续6
- trusted-set-local-storage-item.js ↪
- trusted-set-session-storage-item.js ↪
- adjust-setInterval.js ↪
- nano-setInterval-booster.js /
- nano-sib.js
- spoof-css.js ↪
- prevent-canvas.js ↪
- prevent-dialog.js ↪
- adjust-setTimeout.js ↪
- nano-setTimeout-booster.js /
- nano-stb.js
- ~sharedWorker-defuser.js~ ↪
- webrtc-if.js ↪
- close-window.js ↪
- window-close-if.js
- prevent-window-open.js ↪
- nowoif.js /
- no-window-open-if.js /
- window.open-defuser.js
- window.name-defuser ↪
- overlay-buster.js ↪
- alert-buster.js ↪
- edit-suite of scriptlets
Resources Library·续6
Set a local/session storage entry to a specific, allowed value. Scriptlet won't set item if storage is full. Double quotes surrounding the key value are allowed.
- required, key name to be set.
- required, key value; possible values:
- decimal integer
>= -32767 && <= 32767(only<= 32767up to <sup>1.61.1b1</sup>) - one of the predefined constants:
'': empty stringundefined,nullfalse,trueon,offyes,noaccept,reject<sup>1.57.3b9</sup>accepted,rejected<sup>1.57.3b9</sup>allowed,denied<sup>1.59.1b5</sup>- any from
set-cookie<sup>1.59.1b5</sup> {}: empty object[]: empty array""$remove$: remove specific item from localStorage
- decimal integer
Examples:
- example.com##+js(set-local-storage-item, player.live.current.mute, false)
- example.com##+js(set-local-storage-item, exit-intent-marketing, 1)
- example.com##+js(set-local-storage-item, foo, $remove$)
- example.com##+js(set-session-storage-item, player.live.current.mute, false)
- example.com##+js(set-session-storage-item, exit-intent-marketing, 1)
- example.com##+js(set-session-storage-item, foo, $remove$)
Solves uBlockOrigin/uBlock-issues#2697.
Also see:
- trusted-set-local-storage-item
- AdGuard set-local-storage-item
trusted-set-local-storage-item.js ↪
trusted-set-session-storage-item.js ↪
Trusted scriptlet
New in 1.50.1b4 and 1.53.5rc7.
Parameters:
- required, key name to be set.
- required, key value; possible values:
- arbitrary value
- $now$: keyword for setting current time in ms,
corresponds to Date.now() and (new Date).getTime() calls, can be used inside a string since 1.57.3b8
- $currentDate$: keyword for setting string representation of the current date and time,
corresponds to Date() and (new Date).toString() calls, can be used inside a string since 1.57.3b8
- $currentISODate$: keyword for setting string representation of the current date and time in ISO format,
corresponds to Date() and (new Date).toISOString() calls, can be used inside a string since 1.57.3b8
Examples:
- example.com##+js(trusted-set-local-storage-item, COOKIE_CONSENTS, {"preferences":3\,"flag":false})
- example.com##+js(trusted-set-local-storage-item, providers, [16364\,88364])
- example.com##+js(trusted-set-local-storage-item, player.live.current.play, $currentDate$)
- example.com##+js(trusted-set-local-storage-item, ppu_main_none, '')
- example.com##+js(trusted-set-session-storage-item, opd, 1.4)
Also see:
- set-local-storage-item
- AdGuard trusted-set-local-storage-item
adjust-setInterval.js ↪
nano-setInterval-booster.js /
nano-sib.js
Adjusts interval for specified setInterval() callbacks.
Parameters:
- optional, string/regular expression, matching in stringified callback function
- optional - defaults to 1000, decimal integer, matching interval. New in 1.33.0: * will match any interval.
- optional - default to 0.05 (20x faster), float, capped at 50 times for up and down, interval multiplier
Examples:
- identi.li##+js(nano-sib, , ,0.02)
- platinmods.*##+js(nano-sib)
- 1ink.cc##+js(nano-sib, mSec, 1050)
Also see:
- AdGuard adjust-setinterval
spoof-css.js ↪
Spoof the CSS property value when getComputedStyle() or getBoundingClientRect() are used.
Parameters: - required, a valid CSS selector which matches the elements for which the spoofing must apply - required, a CSS property name (can be dashed- or camel-cased) - required, the value to return regardless of the currently computed value
Examples:
- adblock
example.com##+js(spoof-css, .ad, clip-path, none)
example.com##+js(spoof-css, .ad, _debug, 1)
There can be any number of selectors, grouped inside single quotes:
adblock example.com##+js(spoof-css, 'a[href="x.com"], .ads, .bottom', clip-path, none)
There can be any number of property-name/property-value pairs, all separated by commas:
adblock example.com##+js(spoof-css, .ad, clip-path, none, display, block)
Special properties: <sup>1.61.1b4</sup>
- _debug, 1: Force the browser to break when getComputedStyle() or getBoundingClientRect() is called, useful to help pinpoint usage of those calls in the page's source code.
- _rectx, value: Spoof the DOMRect.x returned by getBoundingClientRect().
- _recty, value: Spoof the DOMRect.y returned by getBoundingClientRect().
- _rectw, value: Spoof the DOMRect.width returned by getBoundingClientRect().
- _recth, value: Spoof the DOMRect.height returned by getBoundingClientRect().
If both _rectw and width are present in the list of properties to spoof, _rectw will have precedence over width in the spoofing of getBoundingClientRect() output. Same for _recth.
Solves uBlockOrigin/uBlock-issues#2618.
Also see:
- AdGuard spoof-css
prevent-canvas.js ↪
New in 1.52.3b2
Prevent usage of specific or all (default) canvas APIs.
Syntax:
- example.com##+js(prevent-canvas [, contextType])
Parameters:
- optional, contextType: A specific type of canvas API to prevent (default to all
APIs). Can be a string or regex which will be matched against the type
used in getContext() call. Prepend with ! to test for no-match.
Examples:
- example.com##+js(prevent-canvas) - prevents example.com from accessing all canvas APIs
- *##+js(prevent-canvas, /webgl/) - prevents access to any flavor of WebGL API, everywhere
- example.com##+js(prevent-canvas, !2d) - prevents example.com from accessing any flavor of canvas API except 2d
References: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
prevent-dialog.js ↪
New in 1.68.1b0
Programmatically close dialog elements.
Parameters:
- optional, an additional selector used to choose which dialog elements
to close. The word dialog is added automatically and should not be
included in the parameter.
Examples:
* example.com##+js(prevent-dialog)
* example.com##+js(prevent-dialog, [open])
* flip.hu##+js(prevent-dialog, :has(.cookie-modal))
adjust-setTimeout.js ↪
nano-setTimeout-booster.js /
nano-stb.js
Adjusts delay for specified setTimeout() callbacks.
Parameters:
- optional, string/regular expression, matching in stringified callback function
- optional - defaults to 1000, decimal integer, matching delay. New in 1.33.0: * will match any delay.
- optional - default to 0.05 (20x faster), float, capped at 50 times for up and down, delay multiplier
Examples:
- bdupload.*##+js(nano-stb)
- imgrock.*##+js(nano-stb, /.?/, 4000)
Also see:
- AdGuard adjust-settimeout
~sharedWorker-defuser.js~ ↪
Removed. Deprecated by $csp filter option.
Defuses sharedWorker by passing empty worker file (Blob URL) for specified worker URLs
Parameters: - optional, string/regular expression, matching in worker URL
webrtc-if.js ↪
Allows opening RTC connections to matching RTCIceServer only.
Parameters:
- required, string/regular expression, matching in RTCIceServer urls, username or credential.
close-window.js ↪
window-close-if.js
New in 1.39.3b10.
Closes fresh browser tabs of the specified page. Can also be used to close tabs which have been opened from other applications. Can be narrowed down to specific path by parameter. Whole browser window will be closed if it's the last/only tab (depends on browser configuration).
Improvements:
- 1.44.3b11, If the argument to the window-close-if scriptlet is a regex, the
match will be against the whole location URL, otherwise the
match will be against the part+query part of the location URL.
Parameters:
- optional, string, matching in the path and query part of the web page address or regular expression, matching in the whole location URL.
Examples:
acestream.com##+js(window-close-if, /plan/select?popup=noads)example.com##+js(window-close-if, /^/)- will close all new tabs going toexample.comon any site.hostdl.com##+js(window-close-if, /^https?://(www\.)?hostdl\.com/)- will close all new tabs matching either only base domain or www one (i.e. notlogin.hostdl.com).
Also see:
- AdGuard close-window
prevent-window-open.js ↪
nowoif.js /
no-window-open-if.js /
window.open-defuser.js
Prevent opening new windows by window.open() when URL positively or negatively matches to specific string.
Improvements:
- 1.29.2, third parameter can now configure behavior of the scriptlet.
- 1.27.0,
nowoif.jsalias is now available. - 1.26.0 (one, two),
if second argument is present and a valid integer value, the defuser will return a valid window object even though no popup window is opened. The returned window object will cease to be valid after the specified number of seconds. If not present, no window will be opened and the scriptlet will returnnull.
If the first argument is set to the special value debug and the logger is opened, the scriptlet will trigger a debugger statement and the prevention will not occur.
When used without parameters, will log calls to window.open() to the logger.
Parameters:
- optional, string/regular expression, prefixed by ! for negation, matching in all parameters passed to window.open() (all the arguments are joined as a single space-spearated string, and the result is used as the target for matching the pattern, new in 1.50.1b2), if not provided, all calls to window.open() are prevented.
- optional, positive decimal integer, number of seconds after returned window object will be invalidated.
- optional, possible values:
- obj: Use an object element instead of iframe element (default) as a decoy to be used in place of a popup window, when the page requires a valid window instance to be returned.
- blank: Replace the url parameter with about:blank. <sup>1.59.1b9</sup>
Tokens:
- ~~log, 1~~: Cause the scriptlet to log information regarding how window.open() is used by the page on which the scriptlet is used.
(deprecated, read about the new method of logging scriptlets)
Examples:
- file-up.org##+js(nowoif)
- vidstream.*##+js(nowoif, !api?call=, 10, obj)
- example.com##+js(nowoif, download-link, , , log, 1)
Also see:
- AdGuard prevent-window-open
window.name-defuser ↪
Clears window.name property which can be misused for tracking purposes.
Parameters: - none
overlay-buster.js ↪
Experimental, gets rid of overlay dialogs, works for ~30s after page load. Preferred way to handle overlays is to use standard cosmetic filters and optionally style injection.
alert-buster.js ↪
Disables alert() dialog boxes by redirecting messages to console.
edit-suite of scriptlets
All the edit-related scriptlets below rely on using uBO-flavored JSONPath queries. These scriptlets are used to remove properties from inbound, outbound, or looked up objects in various contexts.
All these scriptlets have a trusted-[name of the scriptlet] version, which allows to change the value of properties looked up by the specified JSONPath. The non-trusted version can only cause looked up properties to be removed.
edit-outbound-object
Prune properties from an object returned by a specific method.
Parameters: - Required, property chain of the method to trap. - Required, a uBO-flavored JSONPath query.
edit-inbound-object
Prune properties from an object passed as argument to a specific method.
Parameters: - Required, property chain of the method to trap. - Required, the 0-based position of the argument to edit. Use negative integer for position relative to the end - Required, a uBO-flavored JSONPath query.
