Opened 6 months ago

Last modified 6 months ago

#7207 closed change

Implement abort-on-property-write snippet — at Version 2

Reported by: hfiguiere Assignee:
Priority: P2 Milestone:
Module: Core Keywords: circumvention
Cc: mjethani, arthur Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

Description (last modified by hfiguiere)


Similarly to issue #6969

Some circumvention scripts depend on global properties on the window object. The execution of such scripts can be aborted by throwing an error when the property is written (set).

There is a technique in uBlock Origin called abort-on-property-write that does this.

What to change

Implement a snippet called abort-on-property-write that wraps a given property of the window object and throws an error if the property is written (set).

Hints for testers

Try this:

<!-- test.html -->
  Lorem ipsum dolor sit amet, consectetur
  adipiscing elit, sed do eiusmod tempor
  incididunt ut labore et dolore magna aliqua.
<script src="script.js"></script>
/* script.js */
setTimeout(() =>
  if (!window.adsShowing)
    window.adsShowing = true;
    let ad = document.createElement("div"); = Math.random().toString(36).substring(2);
    ad.innerHTML = "<div><span>Check this!</span><span class='label'>Ad</span></div>";

When you load this page, it should show the "Check this!" ad. If you then add the filter localhost#$#abort-on-property-write adsShowing and reload the page, the ad should no longer be shown. Also there should be no error in the tab's console.

Change History (2)

comment:1 Changed 6 months ago by hfiguiere

  • Cc mjethani arthur added

comment:2 Changed 6 months ago by hfiguiere

  • Description modified (diff)
Note: See TracTickets for help on using tickets.