Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Byepopups!
// ==UserScript==
// @name Byepopups!
// @namespace http://mehmetefeakca.me/
// @version 0.001
// @description try to remove all those nasty popups that happen when you click anything in the website! They do suck..
// @author MMTF
// @match *://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
//
// WARNING: THE CODE BELOW DOES NOT BELONG TO ME
//
// That code is written by eligrey to replace the Object.prototype.watch function. The code is released under the public domain.
// Thank you so much eligrey! This extension would be useless without your snippet.
// Link to original post by eligrey:
// https://gist.github.com/eligrey/384583
//
// I only wrote the code that uses eligrey's function
//
if (!Object.prototype.watch) {
Object.defineProperty(Object.prototype, "watch", {
enumerable: false, configurable: true, writable: false, value: function (prop, handler) {
var oldval = this[prop], newval = oldval, getter = function () {
return newval;
}, setter = function (val) {
oldval = newval;
return newval = handler.call(this, prop, oldval, val);
};
if (delete this[prop]) { // can't watch constants
Object.defineProperty(this, prop, {get: getter, set: setter, enumerable: true, configurable: true});
}
}
});
}
// object.unwatch
if (!Object.prototype.unwatch) {
Object.defineProperty(Object.prototype, "unwatch", {
enumerable: false, configurable: true, writable: false, value: function (prop) {var val = this[prop];
delete this[prop]; // remove accessors
this[prop] = val;
}
});
}
// Use document.unwatch('onclick') for re-enabling document click events, use when needed in your dev tools console.
document.watch('onclick', function(obj, prop, oldval, val){return undefined;});
/*
Old and very performance-unfriendly way of doing this. I literally killed it.
Note: There is no other absolute way of blocking the popups. This is a universal fix for popups that depend on document.onclick events.
setTimeout(function(){
document.onclick = undefined;
setTimeout(function(){
document.onclick = undefined;
setTimeout(function(){
document.onclick = undefined;
setTimeout(function(){
document.onclick = undefined;
setTimeout(function(){
document.onclick = undefined;
setTimeout(function(){
document.onclick = undefined;
setTimeout(function(){
document.onclick = undefined;
}, 500);
}, 500);
}, 500);
}, 500);
}, 500);
}, 500);
}, 500);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.