LogoLogo
About GitLabAcceptable Ads
  • Getting Started
  • Browser Ad-Filtering Solution
    • Features
    • Getting Started
      • Quickstart
      • Integrate the Solution
      • Set up user counting
    • Guides
      • User counting
      • Configure Solution settings
      • Run separate instances of the filtering engine
      • Update the Solution
      • Understand the snippets library
      • Create a filter list
      • Testing
    • Advanced
      • Services and classes
      • Sitekey
      • ADRs
      • Frame hierarchy
  • Snippets
    • Snippets Overview
    • Behavioral Snippets
      • abort-current-inline-script
      • abort-on-property-read
      • abort-on-property-write
      • abort-on-iframe-property-read
      • abort-on-iframe-property-write
      • array-override
      • cookie-remover
      • freeze-element
      • json-override
      • json-prune
      • override-property-read
      • prevent-listener
      • replace-fetch-response
      • replace-xhr-response
      • simulate-mouse-event
      • skip-video
      • strip-fetch-query-parameter
    • Conditional Hiding Snippets
      • hide-if-canvas-contains
      • hide-if-contains
      • hide-if-contains-image
      • hide-if-contains-similar-text
      • hide-if-contains-visible-text
      • hide-if-contains-and-matches-style
      • hide-if-has-and-matches-style
      • hide-if-labelled-by
      • hide-if-matches-computed-xpath
      • hide-if-matches-xpath
      • hide-if-matches-xpath3
      • hide-if-shadow-contains
    • Debugging Snippets
      • debug
      • log
      • profile
      • trace
    • Performance Snippets
      • race
    • Snippets Support by Platform
    • Node Highlighting
    • Accessing shadow DOM elements
  • Working with filters
  • DATA AND PRIVACY
    • Data collection at eyeo
Powered by GitBook
On this page
  • Parameters
  • Filter examples
  • Debugging
  • Tradeoffs

Was this helpful?

Edit on GitLab
Export as PDF
  1. Snippets
  2. Behavioral Snippets

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 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

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

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. This function is a property of cmd, which is a property of the adHandler global object.

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

The code that sets the AdblockCookieMatchingType property throws an exception.

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

Debugging

The following table contains messages you'll find useful during debugging:

Message
When the error occurs
Definition

no property to abort on write

At the beginning of snippet execution

No property parameter was passed to the snippet.

setting <property> aborted

Each time the property is set, right before throwing the error

The error is about to be thrown.

aborting when setting <property>

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-writefilter:

  • 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 1 year ago

Was this helpful?