The function(s) we want to override. If you pass a function you need to implement the overriding for the original function yourself. Otherwise you can pass an object defining the object itself and the appropriate key which holds the function so it gets overwritten automatically.
Allows you to define a function which needs to return a boolean
which allows synced execution.
If the return is a Promise
it will return the Promise
immediately, when the Promise
gets resolved the
original function gets invoked.
Optional
failedOptional
skipFunction which calls original function when consent is given (depending on checkExecution
) or undefined
if an undefined function was passed as argument.
Wrap any function into a consent-awaiting function. This allows you to e.g. overwrite every function a WordPress theme or plugin is exposing to
window
object.Learn usage by example
A plugin exposes the following function which loads a Google Map to
window
:We can now override this method with the help of
idx
and delay of theconsole.log
until consent for Google Maps is given:The example above can also be used in the following way to check for blocker rules for the given function body:
The above examples determine the consent by a defined Content Blocker. But you can also wait for consent by a defined service with the help of the
consent
API to check for a technical definition (HTTP Cookie, LocalStorage, ...):And for the advanced usages, you can simply return your own
boolean
orPromise
by passing your custom checker:If you are invoking
wrapFn
at the very beginning of your HTML and you do not know, when the function which should be overwritten is available, you can pass a function toobject
so it gets retried to overwrite oninteractive
andcomplete
state: