Created
January 7, 2017 18:08
-
-
Save aaronfc/fcc1ee1315692b004b91305da48a5b2a to your computer and use it in GitHub Desktop.
Remove suspicious click events to avoid first click ads.
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
// ==UserScript== | |
// @name New Userscript | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://mail.google.com/mail/u/0/#inbox | |
// @grant none | |
// ==/UserScript== | |
function removeSuspiciousClickEvents(target) { | |
const events = getEventListeners(target); | |
if (events.click) { | |
events.click.forEach(function (e) { | |
target.removeEventListener("click", e.listener, false); | |
}); | |
} | |
if (events.mousedown) { | |
events.mousedown.forEach(function (e) { | |
target.removeEventListener("mousedown", e.listener, false); | |
}); | |
} | |
if (events.mouseup) { | |
events.mouseup.forEach(function (e) { | |
target.removeEventListener("mouseup", e.listener, false); | |
}); | |
} | |
} | |
(function() { | |
'use strict'; | |
window.addEventListener('load', function() { | |
removeSuspiciousClickEvents(document); | |
removeSuspiciousClickEvents(document.body); | |
removeSuspiciousClickEvents(window); | |
}, false); | |
})(); |
Because getEventListeners
is only available when using DevTools
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
getEventListeners(target) give me an error "ReferenceError: getEventListeners is not defined"