Skip to content

Instantly share code, notes, and snippets.

@maziara
Last active December 25, 2016 22:12
Show Gist options
  • Save maziara/e15091e275e9f018aa71a5fcd5c5389f to your computer and use it in GitHub Desktop.
Save maziara/e15091e275e9f018aa71a5fcd5c5389f to your computer and use it in GitHub Desktop.
A TamperMonkey script for disabling the click popups that advertisers use on the whole document.
// ==UserScript==
// @name Disable DocumentClick
// @namespace https://github.com/maziara/DisableDocumentClick
// @updateURL https://raw.githubusercontent.com/maziara/DisableDocumentClick/master/DisableDocumentClick.js
// @version 0.1
// @description Disabling the click popups that advertisers use on the whole document.
// @author Maziara
// @include *
// @grant none
// ==/UserScript==
(function() {
var counter = 0;
var i = setInterval(function(){
// do your thing
//console.log(document.onclick);
if (typeof(document.onclick) == "function"){
disableDocumentClick();
}
if (typeof(document.mousedown) == "function"){
disableDocumentMouseDown();
}
counter++;
if(counter === 30) {
clearInterval(i);
}
}, 200);
function disableDocumentClick(){
console.log("***** document.click event detected. Disabling...");
document.onclick = undefined;
}
function disableDocumentMouseDown(){
console.log("***** document.click event detected. Disabling...");
document.mousedown = undefined;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment