@trustedScriptlet trusted-set-attr
@description
Sets the specified attribute on the specified elements. This scriptlet runs
once when the page loads then afterward on DOM mutations.
Reference: https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-trusted-scriptlets.md#-%EF%B8%8F-trusted-set-attr
@param selector
A CSS selector for the elements to target.
@param attr
The name of the attribute to modify.
@param value
The new value of the attribute. Since the scriptlet requires a trusted
source, the value can be anything.
=====
Additionally, start to move scriptlets into their own source files
for easier maintenance and code review.
BroadcastChannel constructor throws in Firefox when Enhanced
Tracking Protection is set to "strict".
This behavior could cause scriptlet injection to wholly break
when uBO's logger was opened, as BroadcastChannel() is used
by scriptlets to report information to the logger.
This commit ensures that exceptions from BroadcastChannel
constructor are properly handled.
The scriptlets will fall back to report at the console should
they be unable to report to the logger through BroadcastChannel.
@description
Override the behavior of a method on matching elements.
@param methodPath
The method which calls must be intercepted.
@param [selector]
A CSS selector which the target element must match. If not specified,
the override will occur for all elements.
@param [disposition]
How the override should be handled. If not specified, the overridden call
will be equivalent to an empty function. If set to `throw`, an exception
will be thrown. Any other value will be validated and returned as a
supported safe constant.
@example
..##+js(trusted-override-element-method, HTMLAnchorElement.prototype.click, a[target="_blank"][style])
@description
Prevent the bypassing of uBO scriptlets through anonymous embedded context.
To ensure that a target method in the embedded context is using the
corresponding parent context's method (which is assumed to be
properly patched), or to replace the embedded context with that of the
parent context.
Root issue:
https://issues.chromium.org/issues/40202434
@param methodPath
The method which calls must be intercepted. The arguments
of the intercepted calls are assumed to be HTMLElement, anything else will
be ignored.
@param selector (optional)
A plain CSS selector which will be used in a `document.querySelector()`
call, to validate that the returned element must be processed by the
scriptlet. If no selector is provided, all elements will be processed.
@param targetMethod (optional)
The method in the embedded context which should be delegated to the
parent context. If no method is specified, the embedded context becomes
the parent one, i.e. all properties of the embedded context will be that
of the parent context.
Add support for synchronous `send()` calls.
`trusted-prevent-xhr` is essentially the same as `prevent-xhr` 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.
Probably beneficial in cases of proxied method called in a tight
loop.
Additionally, added `throwFunc` as valid constant in script helper
`validate-constant.fn`. Does what the name implies.
When the replacement starts with `json:`, it will be first
decoded using JSON.parse(). Example:
example.com##+js(trusted-replace-outbound-text, somefn, json:"ok")
The doublequotes are required since this is what JSON.parse()
expects as a valid JSON string.
This helper function is now used by `set-cookie` and
`set-local-storage-item` scriptlets, so changes in the
helper function will benefit both scriptlets.
Add `statusText` as overridable property in response instance.
Supported values are: `""`, `"Not Found"`. `statusText` defaults
to `"OK"` when not overridden.