Opened 3 months ago

Last modified 3 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):

https://codereview.adblockplus.org/29979555/

Description (last modified by hfiguiere)

Background

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

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 3 months ago by hfiguiere

  • Cc mjethani arthur added

comment:2 Changed 3 months ago by hfiguiere

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