abort-on-property-write

abort-on-property-write

The abort-on-property-write snippet patches a property on the window object that aborts execution when the property is written or set. No error gets printed to the console.

Only use this snippet for written properties. Place it just inside the script you want to abort, otherwise, an error will be thrown.

Parameters

Name

Description

Mandatory

property

The name of the property or path to the property (chain of properties separated by dots).

Yes

setConfigurable

Value of the configurable attribute. Defaults to true. Setting to false prevents overwriting.

No

Filter examples

Filter

Result

abort-on-property-write hasAdvert

The code that sets the hasAdvert global property throws an exception.

abort-on-property-write adHandler.cmd.push

The code that sets the push function throws an exception.

abort-on-property-write Object.prototype.AdblockCookieMatchingType

The code that sets the AdblockCookieMatchingType property throws an exception.

Debugging

Message

When

Definition

no property to abort on write

Beginning of execution

No property parameter was passed.

setting <property> aborted

Each time property is set

The error is about to be thrown.

aborting when setting <property>

Before attaching to property

Snippet is taking over the property getter/setter.

Tradeoffs

  • The snippet is executed after all of a page's inline scripts.

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

  • You should only attach to properties set just inside the script you want to abort.