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.
You can use this snippet to abort the execution of inline scripts.
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. If the property is a direct child of | yes |
setConfigurable | Value of the configurable attribute of the descriptor of property. If this parameter is not used it defaults to true. Setting it to false will prevent the property set and get being overwritten or otherwise changed by anybody. If this snippet doesn't work as expected when passing only the property, it could mean that the website is circumventing and setting this parameter to false can come in handy. | No |
Filter examples
The following table lists examples that use the abort-on-property-write
snippet:
Filter | Result |
---|---|
| The code that sets the |
| The code that sets the |
| The code that sets the This example shows that you can attach the filter to |
Debugging
The following table contains messages you'll find useful during debugging:
Message | When the error occurs | Definition |
---|---|---|
| At the beginning of snippet execution | No |
| Each time the property is set, right before throwing the error | The error is about to be thrown. |
| Right before attaching to the property | This log is printed just before the snippet takes over the property getter OR setter. |
Tradeoffs
Keep the following tradeoffs in mind when you use the abort-on-property-write
filter:
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.You should only attach to properties set just inside the script you want to abort. Otherwise, an error will be thrown.
Last updated