Skip to content

Commit

Permalink
Detect/prevent the creation of already existing iframe tags
Browse files Browse the repository at this point in the history
Related issue:
- uBlockOrigin/uBlock-issues#786

A case of web page embedding multiple times the
`adsbygoogle.js` script was causing the neutered,
replacement script to create a huge amount of iframes
in the DOM.

The scriptlet has been modified to check if an iframe
tag already exist and skip the creation if so.
  • Loading branch information
gorhill committed Nov 19, 2019
1 parent 18b6a6b commit bdd4a5b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/web_accessible_resources/googlesyndication_adsbygoogle.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
const css = 'height:1px!important;max-height:1px!important;max-width:1px!important;width:1px!important;';
for ( let i = 0; i < phs.length; i++ ) {
const fr = document.createElement('iframe');
fr.id = 'aswift_' + (i+1);
const id = `aswift_${(i+1)}`;
if ( document.querySelector(`iframe#${id}`) !== null ) { continue; }
fr.id = id;
fr.style = css;
const cfr = document.createElement('iframe');
cfr.id = 'google_ads_frame' + i;
cfr.id = `google_ads_frame${i}`;
fr.appendChild(cfr);
document.body.appendChild(fr);
}
Expand Down

0 comments on commit bdd4a5b

Please sign in to comment.