Last active
December 27, 2019 17:51
-
-
Save AdrianSkar/ff8c1d6a41fe59144242eabd057c4c51 to your computer and use it in GitHub Desktop.
Toggle off Outlook advertising vendors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/2705583/how-to-simulate-a-click-with-javascript | |
function eventFire(el, etype){ | |
if (el.fireEvent) { | |
el.fireEvent('on' + etype); | |
} else { | |
var evObj = document.createEvent('Events'); | |
evObj.initEvent(etype, true, false); | |
el.dispatchEvent(evObj); | |
} | |
} | |
// Create an array and store HTML ids on it | |
let store = []; | |
for (let i = 1; i <= 6000; i++) { | |
let target = 'Toggle'.concat(i); | |
target.toString(); | |
if (document.getElementById(target) != undefined) { | |
store.push(target); | |
} | |
} | |
// Trigger click events on each id | |
for (let y = 0; y < store.length; y++) { | |
eventFire(document.getElementById(store[y]), 'click'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment