- Resources Library·续2
- json-prune-xhr-response.js ↪
- xml-prune.js ↪
- m3u-prune.js ↪
- noeval.js ↪
- noeval-silent.js /
- ~silent-noeval.js~ ↪
- noeval-if.js ↪
- prevent-eval-if.js
- ~no-floc.js~ ↪
- prevent-fetch.js ↪
- no-fetch-if.js
- trusted-prevent-fetch.js ↪
- trusted-replace-xhr-response.js ↪
- trusted-replace-fetch-response.js ↪
- trusted-rpfr.js
- trusted-replace-argument.js ↪
- prevent-requestAnimationFrame.js ↪
- no-requestAnimationFrame-if.js /
- norafif.js
Resources Library·续2
Examples:
tumblr.com##+js(json-prune-fetch-response, response.timeline.elements.[-].advertiserId, , propsToMatch, url:/api/v2/tabs/for_you)
nbc.com##+js(json-prune-fetch-response, avails, , propsToMatch, amazonaws.com)
Also see:
- AdGuard json-prune-fetch-response
json-prune-xhr-response.js ↪
New in 1.51.1rc3
Removes specified properties from the JSON response of a XMLHttpRequest call.
For usage, see: json-prune-fetch-response
Example:
www.facebook.com##+js(json-prune-xhr-response, data.viewer.instream_video_ads data.scrubber, , propsToMatch, /api/graphql)
Also see:
- AdGuard json-prune-xhr-response
xml-prune.js ↪
Removes an element from the specified XML retrieved using fetch, xhr support was added in 1.49.3rc6.
New in 1.44.5b3
After 1.49.3rc16, it can also remove attributes.
Parameters: - required, a selector of elements or xpath of elements/attributes <sup>(New in 1.49.3rc16)</sup> which are to be removed. - optional, a selector or xpath <sup>(New in 1.49.3rc15</sup> that must have a match in the document for the pruning to occur. No selector means the pruning can be performed regardless. - optional, a URL which must be a match for the pruning to occur. If left blank, the pruning can be performed regardless.
Tokens:
- ~~log, 1~~ (deprecated, read about the new method of logging scriptlets)
- logdoc, 1: Dumps the whole document being worked on to the logger
Examples:
- cbs.com##+js(xml-prune, Period[id*="-roll-"][id*="-ad-"], , pubads.g.doubleclick.net/ondemand)
- play.max.com##+js(xml-prune, xpath(//*[name()="Period"][not(.//*[name()="SegmentTimeline"])]), , .mpd)
- example.com##+js(xml-prune, xpath(//*[name()="MPD"]/@mediaPresentationDuration), , .mpd, log, 1)
Also see:
- AdGuard xml-prune
m3u-prune.js ↪
New in 1.44.5b6
Sometimes sites serve real video content and video ads all in one place inside .m3u8 files.
You can use m3u-prune to remove those ad segments.
Examples:
- player.theplatform.com##+js(m3u-prune, tvessaiprod.nbcuni.com, /theplatform\.com\/.*?\.m3u8/)
- mephimtv.cc##+js(m3u-prune, /#EXT-X-DISCONTINUITY(.|\n){1\,100}#EXT-X-DISCONTINUITY/gm, mixed.m3u8)
If the first argument is a regex with multiline flag set, the scriptlet will execute the regex against the whole text and remove matching text from the whole text (New in 1.47.5b10).
If the matching text does not contain whole lines, the text won't be removed, i.e. it is not allowed to remove only part of a line.
Also see:
- AdGuard m3u-prune
noeval.js ↪
Prevent web pages from using eval(), and report attempts to the logger. This should not be used as a generic filter due to the fact that it breaks many websites, including those using Cloudflare's DDoS protection.
Examples:
- solowarez.org##+js(noeval)
Also see:
- AdGuard noeval
noeval-silent.js /
~silent-noeval.js~ ↪
Prevent web pages from using eval().
noeval-if.js ↪
prevent-eval-if.js
Prevent web pages from using eval() on specific matching payloads.
Parameters: - optional, string/regular expression, matching in payload string.
When used without parameters, will log calls to eval() to the logger.
Examples:
- orgyxxxhub.com##+js(noeval-if, replace)
~no-floc.js~ ↪
Obsolete: FLoC ended its experiment in July of 2021.
New in 1.35.0.
Defuses Google FLoC ("Federated Learning of Cohorts") tracking. Read more on https://amifloced.org/
uBlock Origin (uBO) ensures FLoC is opt-in. The generic filter *##+js(no-floc) in "uBlock filters -- Privacy" ensures the feature is disabled when using default settings/lists.
Users can opt-in to FLoC by adding a generic exception filter to their custom filters, #@#+js(no-floc); or they can opt-in only for a specific set of websites through a more specific exception filter:
example.com,shopping.example#@#+js(no-floc)
Solves uBlockOrigin/uBlock-issues#1553.
prevent-fetch.js ↪
no-fetch-if.js
New in 1.31.3b9.
Defuses calls to fetch() by returning a promise which always resolve to an empty response.
Parameters:
- optional, space-separated list of conditions which must be ALL fulfilled in order for the defusing to take place:
- string/regular expression, prefixed by ! for negation (new in 1.59.1b13), matching in URL passed to fetch() call
- colon-separated name:value pairs of init option name and string/regular expression matching in value of that option passed to fetch() call.
- optional, directive; arguments to define the response body:
- true to randomize the response, random 10-character string <sup>1.51.1b15</sup>
- emptyObj to return the response value as empty object <sup>1.54.1rc2</sup>
- emptyArr to return the response value as empty array <sup>1.54.1rc2</sup>
- emptyStr to return the response value as empty string <sup>1.54.1rc2</sup>
- length:min[-max] to fulfill the response with randomized text with length specified, limited to 500000 characters <sup>1.54.1b1</sup>
- war:[name of resource] to fulfill the response with the content of a web_accessible_resources resource <sup>1.54.1b1</sup>
- optional, (new in 1.58.1rc4), string for defining response type / JSON string with
properties to set on the returned response instance, original response type is used if not specified:
- ok, supported values: false, true
- type, supported values: "basic", "cors", "default", "error", "opaque"
- statusText, supported values: "", "Not Found". defaults
to "OK" when not overridden. <sup>1.58.1rc5</sup>
When used without parameters, the parameters passed to no-fetch-if will be logged to the logger.
Examples:
example.com##+js(no-fetch-if, method:HEAD)
example.com##+js(no-fetch-if, adsbygoogle.js)
example.com##+js(no-fetch-if, !negatedValue)
example.com##+js(no-fetch-if, adsbygoogle.js method:HEAD)
example.com##+js(no-fetch-if, /adsbygoogle.js$/ method:/HEAD|POST/)
example.com##+js(no-fetch-if, adsbygoogle.js, length:11000)
example.com##+js(no-fetch-if, adsbygoogle.js, war:googlesyndication_adsbygoogle.js)
example.com##+js(no-fetch-if, doubleclick, , '{"type": "opaque"}')
See also:
- AdGuard prevent-fetch
trusted-prevent-fetch.js ↪
Trusted scriptlet
New in 1.63.3b8
Essentially the same as prevent-fetch except that if the directive argument is not a known token, it will be used as is as the response text of the fetch request, whereas prevent-fetch returns an empty string when the directive is unknown.
trusted-replace-xhr-response.js ↪
Trusted scriptlet
New in 1.51.1rc3
Replaces response text content of xhr requests if all given parameters match.
Parameters:
- required, argument for matching contents of
responseTextthat should be replaced. Possible values: If set,replacementis required. Possible values:*: match all text content- non-empty string
- regular expression
- optional, should be set if first parameter is set. String to replace the response text content matched by pattern. Empty string to remove content. Defaults to empty string.
- optional, string of space-separated properties to match; possible props:
- string or regular expression for matching the URL passed to
XMLHttpRequest.open()call; empty string, wildcard*will match all fetch calls - colon-separated pairs
name:valuewhere:name— string or regular expression for matching XMLHttpRequest property namevalue— string or regular expression for matching the value of the option passed toXMLHttpRequest.open()call
- string or regular expression for matching the URL passed to
Tokens:
- includes, pattern: replace only if pattern match in the text response. Can be a plain string or a regex. <sup>1.58.1b6</sup>
Scriptlet does nothing if response body can't be converted to text.
Example:
- in-jpn.com##+js(trusted-replace-xhr-response, /.*/, , pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?)
Also see:
- AdGuard trusted-replace-xhr-response
trusted-replace-fetch-response.js ↪
trusted-rpfr.js
Trusted scriptlet
New in 1.51.1b8.
Replaces response text content of fetch requests if all given parameters match.
Parameters:
- required, argument for matching contents of responseText that should be replaced. Possible values:
- *: match all text content
- non-empty string
- regular expression
- optional, should be set if first parameter is set. String to replace the response text content matched by pattern. Empty string to remove content. Defaults to empty string.
- optional, string of space-separated properties to match; possible props:
- string or regular expression for matching the URL passed to fetch call; empty string, wildcard * will match all fetch calls
- colon-separated pairs name:value where:
- name is init option name
- value is string or regular expression for matching the value of the option passed to fetch call
Tokens:
- includes, pattern: replace only if pattern match in the text response. Can be a plain string or a regex. <sup>1.58.1b6</sup>
Scriptlet does nothing if response body can't be converted to text.
Solves uBlockOrigin/uBlock-issues#2742.
Examples:
- example.com##+js(trusted-replace-fetch-response, adb_detect:true, adb_detect:false, example.com)
- example.com##+js(trusted-replace-fetch-response, /#EXT-X-VMAP-AD-BREAK[\s\S]*?/, #EXT-X-ENDLIST, example.com)
- example.com##+js(trusted-replace-fetch-response, *, , 'method:GET')
- example.com##+js(trusted-replace-fetch-response, /#EXT-X-VMAP-AD-BREAK[\s\S]*?/, #EXT-X-ENDLIST, '/\.m3u8/ method:/GET|HEAD/')
- example.com##+js(trusted-replace-fetch-response, *, , another_domain.com)
Also see:
- AdGuard trusted-replace-fetch-response
trusted-replace-argument.js ↪
Trusted scriptlet
New in 1.55.1b18
Replace an argument passed to a method.
Syntax:
- [...]##+js(trusted-replace-argument, propChain, argposRaw, argraw [,condition, pattern])
Parameters:
- required, propChain: The property chain to the function which argument must be replaced when called.
- required, argposRaw: The zero-based position of the argument in the argument list. Use a negative number for a position relative to the last argument. Use literal this to replace the value used in prototype-based methods.
- required, argraw: The replacement value, validated using the same heuristic as with the set-constant.js scriptlet.
- If the replacement value matches json:..., the value will be the json-parsed string after json:
- If the replacement value matches repl:/.../.../, the target argument will be replaced according the regex-replacement directive following repl: <sup>1.61.3b1<sup>
If argposRaw parameter is not declared, the scriptlet will log all calls to propChain along with the arguments passed and will not replace the argument passed to the trapped method.
Tokens:
- condition, pattern: The replacement will occur only when pattern matches the target argument.
Examples of usage:
- alliptvlinks.com##+js(trusted-replace-argument, MutationObserver, 0, noopFunc)
- scimagojr.com##+js(trusted-replace-argument, document.querySelector, 0, json:"body", condition, .ad-zone)
- example.com##+js(trusted-replace-argument, String.prototype.split, this, repl:/&ads=1/&ads=0/, condition, ads_enabled=true)
- For illustration, this filter will intercept String.prototype.split method and regex-replace the string before the string is split, see example below.
- var config = "ads_enabled=true&ads=1";
config.split("&");
// &ads=1 will be replaced with &ads=0
Also see:
- AdGuard trusted-replace-argument
