mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-23 02:42:41 +01:00
41876336db
At the moment, the only filter lists deemed from a "trusted source" are uBO-specific filter lists (i.e. "uBlock filters -- ..."), and the user's own filters from "My filters". A new scriptlet which can only be used by filter lists from trusted sources has been introduced: `sed.js`. The new `sed.js` scriptlet provides the ability to perform text-level substitutions. Usage: example.org##+js(sed, nodeName, pattern, replacement, ...) `nodeName` The name of the node for which the text content must be substituted. Valid node names can be found at: https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName `pattern` A string or regex to find in the text content of the node as the target of substitution. `replacement` The replacement text. Can be omitted if the goal is to delete the text which matches the pattern. Cannot be omitted if extra pairs of parameters have to be used (see below). Optionally, extra pairs of parameters to modify the behavior of the scriptlet: `condition, pattern` A string or regex which must be found in the text content of the node in order for the substitution to occur. `sedCount, n` This will cause the scriptlet to stop after n instances of substitution. Since a mutation oberver is used by the scriptlet, it's advised to stop it whenever it becomes pointless. Default to zero, which means the scriptlet never stops. `tryCount, n` This will cause the scriptlet to stop after n instances of mutation observer run (regardless of whether a substitution occurred). Default to zero, which means the scriptlet never stops. `log, 1` This will cause the scriptlet to output information at the console, useful as a debugging tool for filter authors. The logging ability is supported only in the dev build of uBO. Examples of usage: example.com##+js(sed, script, /devtoolsDetector\.launch\(\)\;/, , sedCount, 1) example.com##+js(sed, #text, /^Advertisement$/) |
||
---|---|---|
.. | ||
scriptlets.js |