From 3e8a72ba77e5ac61ef8fdf9ace729a7c76480699 Mon Sep 17 00:00:00 2001 From: D4niloMR <70459964+D4niloMR@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:18:52 -0300 Subject: [PATCH] Updated Resources Library (markdown) --- Resources-Library.md | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/Resources-Library.md b/Resources-Library.md index 5c18d49..7e41ca2 100644 --- a/Resources-Library.md +++ b/Resources-Library.md @@ -474,8 +474,8 @@ Parameters: (as with [`json-prune`](#json-prunejs-)) Varargs: + - `dontOverwrite, 1`: do not modify the target inbound object. - `stackToMatch`: string or regular expression that must match the current function call stack trace. Prepend pattern with `!` to test for unmatched patterns in stack trace. - - `, dontOverwrite, 1`: do not modify the target inbound object Examples: @@ -851,17 +851,26 @@ Syntax: 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. +- 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:` [1.61.3b1](https://github.com/gorhill/uBlock/commit/adced29b5bd26165ca89c4562a048c7e73a667f6) +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 + ``` *** @@ -1065,13 +1074,17 @@ Parameters: - 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`. -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]". + ```adblock + example.com##+js(trusted-set-attr, body, class, some-class) + ``` + +2. Adds a `test-attribute` attribute to the body element with the value `[true, true]`. + + ```adblock + example.com##+js(trusted-set-attr, body, test-attribute, '[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) @@ -1461,10 +1474,9 @@ New in [1.58.1rc0](https://github.com/gorhill/uBlock/commit/97d11c03c2) This is a first draft version with current limitations: - Does not support matching arguments which are object or array -- Does not support `stack` parameter Syntax: -- `example.org#%#//scriptlet('trusted-suppress-native-method', methodPath, signatureStr[, how[, stack]])` +- `example.org##+js(trusted-suppress-native-method, methodPath, signatureStr[, how[, stack]])` Parameters: - methodPath – required, string path to a native method (joined with `.` if needed). The property must be attached to `window`. @@ -1485,7 +1497,9 @@ Tokens: - `debug` – triggers a `debugger` statement and the target method is not suppressed. Useful to find out how the method is being called by the page's code. -- "stack": optional, string or regular expression that must match the current function call stack trace. +- "stack": optional, string or regular expression that must match the current function call stack trace. Prepend pattern with `!` to test for unmatched patterns in stack trace. + +The scriptlet will log stack trace in uBO's logger when verbose mode is enabled. Examples: @@ -1587,7 +1601,6 @@ Parameters: - `on`1 / `off`1, - `true` / `t`3 / `false` / `f`3, - `yes` / `y` / `no` / `n` - - optional, cookie path, defaults to /; possible values: - `/`: root path - `none`: to set no path at all