abort-current-inline-script

This snippet aborts the execution of an inline script when a property is either read or written.

Parameters

NameDescriptionMandatory

api

The API function or property name to anchor on. It can also be the path to that property.

If the property is a direct child of window, this parameter will be the property name. If you want to access a sub property, though, this parameter becomes a chain of properties separated by dots.

Yes

search

If specified, only scripts containing the given string are prevented from executing.

If the string begins and ends with a slash (/), the text in between is treated as a regular expression.

No

Filter examples

The following table lists examples that use the abort-current-inline-script filter:

FilterResult

abort-current-inline-script setDefaultTheme

The code that calls/writes the setDefaultTheme global function throws an exception.

abort-current-inline-script document.head.appendChild

The code that calls/writes the appendChild function throws an exception. This function is a property of head, which is a property of the document global object. Be cautious when using this approach; it blocks any code that appends an element to head.

abort-current-inline-script Object.prototype.networkListener

The code that reads/writes the networkListener property throws an exception.

This example shows that you can attach the filter to prototype properties.

abort-current-inline-script btoa BOOTLOADER_LOADED

The code that calls/writes the btoa global function throws an exception. This filter would only work inside inline scripts whose text content contains the BOOTLOADER_LOADED string.

abort-current-inline-script document.createElement /ru-n4p|ua-n4p|загрузка.../

The code that calls/writes the createElement function of document throws an exception. This filter would only work inside inline scripts whose text content matches the /ru-n4p|ua-n4p|загрузка.../{regex}.

Tradeoffs

Keep the following tradeoffs in mind when you use the abort-current-inline-scriptfilter:

  • The snippet is executed after all of a page's inline scripts. As a result, you should only attach properties read inside of a callback, which can be executed after the script.

  • You can only attach this snippet to global properties, or properties of the window object.

Last updated