diff --git a/Resources-Library.md b/Resources-Library.md index 35838dd..d63413a 100644 --- a/Resources-Library.md +++ b/Resources-Library.md @@ -24,6 +24,7 @@ - [set-constant](#set-constantjs-) _(set)_ - [trusted-set-constant](#trusted-set-constantjs-) _(trusted-set)_ [Trusted] - [trusted-suppress-native-method](#trusted-suppress-native-methodjs-) [Trusted] +- [trusted-override-element-method](#trusted-override-element-methodjs-) [Trusted] - [set-cookie](#set-cookiejs-) - [trusted-set-cookie](#trusted-set-cookiejs-) [Trusted] - [remove-cookie](#remove-cookiejs-) _(cookie-remover)_ @@ -36,11 +37,13 @@ - [nano-setInterval-booster](#nano-setinterval-boosterjs-) _(nano-sib)_ - [nano-setTimeout-booster](#nano-settimeout-boosterjs-) _(nano-stb)_ - [no-xhr-if](#no-xhr-ifjs-) +- [trusted-prevent-xhr](#trusted-prevent-xhrjs-) [Trusted] - [no-fetch-if](#no-fetch-ifjs-) - [trusted-replace-xhr-response](#trusted-replace-xhr-responsejs-) [Trusted] - [trusted-replace-fetch-response](#trusted-replace-fetch-responsejs-) _(trusted-rpfr)_ [Trusted] - [trusted-replace-argument](#trusted-replace-argumentjs-) [Trusted] - [set-attr](#set-attrjs-) +- [trusted-set-attr](#trusted-set-attrjs-) [Trusted] - [remove-attr](#remove-attrjs-) _(ra)_ - [remove-class](#remove-classjs-) _(rc)_ - [remove-node-text](#remove-node-textjs-) _(rmnt)_ @@ -655,7 +658,7 @@ 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](https://github.com/gorhill/uBlock/commit/e8202af11d)), matching in URL passed to `fetch()` call - colon-separated `name:value` pairs of [`init` option name](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) and string/_regular expression_ matching in value of that option passed to `fetch()` call. - - optional, arguments to define the response body, possible values: + - optional, directive; arguments to define the response body: - `true` to randomize the response, random 10-character string [1.51.1b15](https://github.com/gorhill/uBlock/commit/418087d) - `emptyObj` to return the response value as empty object [1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e) - `emptyArr` to return the response value as empty array [1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e) @@ -872,7 +875,7 @@ 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, matching in URL passed to XMLHttpRequest `open()` call - colon-separated `name:value` pairs of [XMLHttpRequest method `open()`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open#parameters) parameter names (only `method` and `url` currently supported) and string/_regular expression_ matching in value of passed argument. - - optional, arguments to define the response body, possible values: + - optional, directive; arguments to define the response body: - `true` to randomize the response, random 10-character string [1.51.1b15](https://github.com/gorhill/uBlock/commit/418087d) - `emptyObj` to return the response value as empty object [1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e) - `emptyArr` to return the response value as empty array [1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e) @@ -895,6 +898,22 @@ Also see: *** +### trusted-prevent-xhr.js [↪](https://github.com/gorhill/uBlock/blob/947602d4fe46ec832d3f95ee3a65633fc4113f44/assets/resources/scriptlets.js#L4173) + +#### _Trusted scriptlet_ + +New in [1.60.1b3](https://github.com/gorhill/uBlock/commit/fe49ced2ac937a8556a19cb61f4c2cb05ab3c54c) + +Essentially the same as [`no-xhr-if`](#no-xhr-ifjs-) except that if the `directive` argument is not a known token, it will be used as is as the response text of the xhr request, whereas `prevent-xhr` returns an empty string when the directive is unknown. + +Examples: +```adblock +anitube.vip##+js(trusted-prevent-xhr, outbrain.com, outbrain) +koramaup.com##+js(trusted-prevent-xhr, googlesyndication, 'a.getAttribute("data-ad-client")||""') +``` + +*** + ### set-attr.js [↪](https://github.com/gorhill/uBlock/blob/786d9b2212e9a2105f516a2ffe5d031da2bdd4b5/assets/resources/scriptlets.js#L2957) New in [1.50.1b16](https://github.com/gorhill/uBlock/commit/786d9b2212e9a2105f516a2ffe5d031da2bdd4b5). @@ -924,6 +943,35 @@ Also see: *** +### trusted-set-attr.js [↪](https://github.com/gorhill/uBlock/blob/947602d4fe46ec832d3f95ee3a65633fc4113f44/assets/resources/attribute.js#L183) + +#### _Trusted scriptlet_ + +New in [1.60.1b17](https://github.com/gorhill/uBlock/commit/11ca4a39239478e35605ec072fca140ac4c70d3b) + +Sets the specified attribute on the specified elements. This scriptlet runs +once when the page loads then afterward on DOM mutations. + +Parameters: + - required, selector: A CSS selector for the elements to target. + - required, attr: The name of the attribute to be added. + - optional, value: The new value of the attribute. Since the scriptlet requires a trusted +source, the value can be anything. + +Examples: +```adblock +example.com##+js(trusted-set-attr, body, class, some-class) +example.com##+js(trusted-set-attr, body, test-attribute, '[true, true]') +``` + +1. Adds a "class" attribute to the body element with the value "some-class". +2. Adds a "test-attribute" attribute to the body element with the value "[true, true]". + +Also see: +- [AdGuard `trusted-set-attr`](https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-trusted-scriptlets.md#-%EF%B8%8F-trusted-set-attr) + +*** + ### ~ra.js~ / ### ~remove-attr.js [↪](https://github.com/gorhill/uBlock/blob/0f330c7359567587df6c35e9108b75c339533a56/assets/resources/scriptlets.js#L658)~ @@ -1351,6 +1399,30 @@ example.org##+js(trusted-suppress-native-method, sessionStorage.setItem, ' |"ite Also see: [AdGuard `trusted-suppress-native-method`](https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-trusted-scriptlets.md#trusted-suppress-native-method) +*** + +### trusted-override-element-method.js [↪](https://github.com/gorhill/uBlock/blob/947602d4fe46ec832d3f95ee3a65633fc4113f44/assets/resources/scriptlets.js#L4267) + +#### _Trusted scriptlet_ + +New in [1.60.1b5](https://github.com/gorhill/uBlock/commit/95b0ce5e3a64d966924dd701d1e336402d586b25) + +Override the behavior of a method on matching elements. + +Parameters: + + - required, methodPath: The method which calls must be intercepted. + - optional, selector: A CSS selector which the target element must match. If not specified, the override will occur for all elements. + - optional, disposition: How the override should be handled. If not specified, the overridden call will be equivalent to an empty function. + - `throw`: an exception will be thrown (throws `ReferenceError`). + - `debug`: triggers a `debugger` statement if uBO's logger is opened. Useful for debugging purposes. + - Any other value will be validated and returned as a supported safe constant. + +Example: +```adblock +streamsilk.com##+js(trusted-override-element-method, HTMLAnchorElement.prototype.click, a[target="_blank"][style]) +``` + *** ### set-cookie.js [↪](https://github.com/gorhill/uBlock/blob/4649ae4d78fa7d46e80d71d39d377d1b65309020/assets/resources/scriptlets.js#L2908)