-
-
Save matthewpenkala/909535551f7cadb973e6714a062781e4 to your computer and use it in GitHub Desktop.
re-enable right click (bookmarklet)
This file contains 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
javascript:(function(w){ | |
var arr = ['contextmenu','copy','cut','paste','mousedown','mouseup','beforeunload','beforeprint']; | |
for(var i = 0, x; x = arr[i]; i++){ | |
if(w['on' + x])w['on' + x] = null; | |
w.addEventListener(x, function(e){e.stopPropagation()}, true); | |
}; | |
for(var j = 0, f; f = w.frames[j]; j++){try{arguments.callee(f)}catch(e){}}})(window); |
PART TWO [minified]
!function(){function r(){this.s=this.m=!1,this.l=["DOMAttrModified","DOMNodeInserted","DOMNodeRemoved","DOMCharacterDataModified","DOMSubtreeModified"],this.bind()}function a(){this.A=window.setTimeout,this.v=window.requestAnimationFrame,this.g=window.Promise,this.h=this.o=!1,window.requestAnimationFrame=window.setTimeout=function(t){t()},window.Promise=function(){this.g.apply(this,arguments),this.h=!0,window.Promise=this.g}}function h(t){this.event=t,this.i=this.createEvent(this.event.type),this.C=this.createEvent("mouseup"),this.j=this.i.defaultPrevented}r.prototype.bind=function(){this.l.forEach(function(t){document.addEventListener(t,this,!0)}.bind(this))},r.prototype.handleEvent=function(){this.m=!0,this.u()},r.prototype.u=function(){this.s||(this.l.forEach(function(t){document.removeEventListener(t,this,!0)}.bind(this)),this.s=!0)},a.prototype.restore=function(){this.o||(window.setTimeout=this.A,window.requestAnimationFrame=this.v,this.h||(window.Promise=this.g),this.o=!0)},h.prototype.createEvent=function(t){var e=this.event.target,i=e.ownerDocument.createEvent("MouseEvents");return i.initMouseEvent(t,this.event.bubbles,this.event.cancelable,e.ownerDocument.defaultView,this.event.detail,this.event.screenX,this.event.screenY,this.event.clientX,this.event.clientY,this.event.ctrlKey,this.event.altKey,this.event.shiftKey,this.event.metaKey,this.event.button,this.event.relatedTarget),i};var d=!(h.prototype.B=function(){var t=this.event.target,e=function(t){this.j=t.defaultPrevented,t.preventDefault()}.bind(this);window.addEventListener(this.event.type,e,!1),t.dispatchEvent(this.i),window.removeEventListener(this.event.type,e,!1),this.j=this.i.defaultPrevented,t.dispatchEvent(this.C)});window.addEventListener("message",function(t){t.data&&"enable-right-click"===t.data.type&&(d=!!t.data.D,t.stopPropagation(),t.stopImmediatePropagation())},!0),window.addEventListener("contextmenu",function t(e){var i,n,o,s;d||(e.stopPropagation(),e.stopImmediatePropagation(),i=new h(e),window.removeEventListener(e.type,t,!0),n=new a,o=new r,s=window.alert,window.alert=function(){},i.B(),window.alert=s,n.restore(),o.u(),window.addEventListener(e.type,t,!0),i.j&&(o.m||n.h)&&e.preventDefault())},!0)}(),function(t){for(var e,i="contextmenu copy cut paste mousedown mouseup beforeunload beforeprint".split(" "),n=0;e=i[n];n++)t["on"+e]&&(t["on"+e]=null),t.addEventListener(e,function(t){t.stopPropagation()},!0);for(i=0;e=t.frames[i];i++)try{arguments.callee(e)}catch(t){}}(window);
! function () {
function e() {
[].forEach.call('contextmenu copy cut paste mouseup mousedown keyup keydown drag dragstart select selectstart'.split(' '), function (t) {
document.addEventListener(t, function (t) {
t.stopPropagation();
}, !0);
});
}
var t = document.createElement('style'),
n = document.head;
t.type = 'text/css';
var i, c, o, a = !(t.innerText = '* {\n -webkit-user-select: text !important;\n -moz-user-select: text !important;\n -ms-user-select: text !important;\n user-select: text !important;\n }'),
s = RegExp('youtube.com|.google.|.google.com|greasyfork.org|twitter.com|instagram.com|facebook.com|translate.google.com|.amazon.|.ebay.|github.|stackoverflow.com|bing.com|live.com|.microsoft.com|dropbox.com|pcloud.com|box.com|sync.com|onedrive.com|mail.ru|deviantart.com|pastebin.com|dailymotion.com|twitch.tv|spotify.com|steam.com|steampowered.com|gitlab.com|.reddit.com').exec(window.location.hostname);
window && null != n && (i = function () {
this.h = [
'DOMAttrModified',
'DOMNodeInserted',
'DOMNodeRemoved',
'DOMCharacterDataModified',
'DOMSubtreeModified'
], this.bind();
}, c = function (t) {
this.event = t, this.g = this.createEvent(this.event.type);
}, s || 1 == a || (o = document, s = document.body, o.oncontextmenu = null, o.onselectstart = null, o.ondragstart = null, o.onmousedown = null, s.oncontextmenu = null, s.onselectstart = null, s.ondragstart = null, s.onmousedown = null, s.oncut = null, s.oncopy = null, s.onpaste = null, [].forEach.call([
'copy',
'cut',
'paste',
'select',
'selectstart'
], function (t) {
document.addEventListener(t, function (t) {
t.stopPropagation();
}, !0);
}), RegExp('example.com|www.example.com').exec(location.hostname) && e(), function () {
try {
GM_registerMenuCommand('Enable Absolute Right Click Mode', function () {
return 1 == confirm('Activate Absolute Right Click Mode!') ? e() : null;
});
} catch (t) {
console.log(t);
}
}(), n.appendChild(t), document.addEventListener('keydown', function (t) {
if (t.ctrlKey && 192 == t.keyCode)
return 1 == confirm('Activate Absolute Right Click Mode!') ? e() : null;
}), a = !0, window.addEventListener('contextmenu', function t(e) {
e.stopPropagation(), e.stopImmediatePropagation();
var n = new c(e);
window.removeEventListener(e.type, t, !0);
var o = new i();
n.i(), window.addEventListener(e.type, t, !0), n.l && o.j && e.preventDefault();
}, !0)), i.prototype.bind = function () {
this.h.forEach(function (t) {
document.addEventListener(t, this, !0);
}.bind(this));
}, i.prototype.handleEvent = function () {
this.j = !0;
}, c.prototype.createEvent = function (t) {
var e = this.event.target,
n = e.ownerDocument.createEvent('MouseEvents');
return n.initMouseEvent(t, this.event.bubbles, this.event.cancelable, e.ownerDocument.defaultView, this.event.detail, this.event.screenX, this.event.screenY, this.event.clientX, this.event.clientY, this.event.ctrlKey, this.event.altKey, this.event.shiftKey, this.event.metaKey, this.event.button, this.event.relatedTarget), n;
}, c.prototype.i = function () {
var t = this.event.target;
(function (t) {
t.preventDefault();
}.bind(this), t.dispatchEvent(this.g), this.l = this.g.defaultPrevented);
});
}(),
function (t) {
for (var e, n = 'contextmenu copy cut paste mousedown mouseup beforeunload beforeprint'.split(' '), o = 0; e = n[o]; o++)
t['on' + e] && (t['on' + e] = null), t.addEventListener(e, function (t) {
t.stopPropagation();
}, !0);
for (n = 0; e = t.frames[n]; n++)
try {
arguments.callee(e);
} catch (t) {}
}(window);
! function () {
function r() {
this.s = this.m = !1, this.l = [
'DOMAttrModified',
'DOMNodeInserted',
'DOMNodeRemoved',
'DOMCharacterDataModified',
'DOMSubtreeModified'
], this.bind();
}
function a() {
this.A = window.setTimeout, this.v = window.requestAnimationFrame, this.g = window.Promise, this.h = this.o = !1, window.requestAnimationFrame = window.setTimeout = function (t) {
t();
}, window.Promise = function () {
this.g.apply(this, arguments), this.h = !0, window.Promise = this.g;
};
}
function h(t) {
this.event = t, this.i = this.createEvent(this.event.type), this.C = this.createEvent('mouseup'), this.j = this.i.defaultPrevented;
}
r.prototype.bind = function () {
this.l.forEach(function (t) {
document.addEventListener(t, this, !0);
}.bind(this));
}, r.prototype.handleEvent = function () {
this.m = !0, this.u();
}, r.prototype.u = function () {
this.s || (this.l.forEach(function (t) {
document.removeEventListener(t, this, !0);
}.bind(this)), this.s = !0);
}, a.prototype.restore = function () {
this.o || (window.setTimeout = this.A, window.requestAnimationFrame = this.v, this.h || (window.Promise = this.g), this.o = !0);
}, h.prototype.createEvent = function (t) {
var e = this.event.target,
i = e.ownerDocument.createEvent('MouseEvents');
return i.initMouseEvent(t, this.event.bubbles, this.event.cancelable, e.ownerDocument.defaultView, this.event.detail, this.event.screenX, this.event.screenY, this.event.clientX, this.event.clientY, this.event.ctrlKey, this.event.altKey, this.event.shiftKey, this.event.metaKey, this.event.button, this.event.relatedTarget), i;
};
var d = !(h.prototype.B = function () {
var t = this.event.target,
e = function (t) {
this.j = t.defaultPrevented, t.preventDefault();
}.bind(this);
window.addEventListener(this.event.type, e, !1), t.dispatchEvent(this.i), window.removeEventListener(this.event.type, e, !1), this.j = this.i.defaultPrevented, t.dispatchEvent(this.C);
});
window.addEventListener('message', function (t) {
t.data && 'enable-right-click' === t.data.type && (d = !!t.data.D, t.stopPropagation(), t.stopImmediatePropagation());
}, !0), window.addEventListener('contextmenu', function t(e) {
var i, n, o, s;
d || (e.stopPropagation(), e.stopImmediatePropagation(), i = new h(e), window.removeEventListener(e.type, t, !0), n = new a(), o = new r(), s = window.alert, window.alert = function () {}, i.B(), window.alert = s, n.restore(), o.u(), window.addEventListener(e.type, t, !0), i.j && (o.m || n.h) && e.preventDefault());
}, !0);
}(),
function (t) {
for (var e, i = 'contextmenu copy cut paste mousedown mouseup beforeunload beforeprint'.split(' '), n = 0; e = i[n]; n++)
t['on' + e] && (t['on' + e] = null), t.addEventListener(e, function (t) {
t.stopPropagation();
}, !0);
for (i = 0; e = t.frames[i]; i++)
try {
arguments.callee(e);
} catch (t) {}
}(window);
FINAL VERSION [minified] ↓
!function(){function e(){[].forEach.call("contextmenu copy cut paste mouseup mousedown keyup keydown drag dragstart select selectstart".split(" "),function(t){document.addEventListener(t,function(t){t.stopPropagation()},!0)})}var t=document.createElement("style"),n=document.head;t.type="text/css";var i,s,o,r=!(t.innerText="* {\n -webkit-user-select: text !important;\n -moz-user-select: text !important;\n -ms-user-select: text !important;\n user-select: text !important;\n }"),a=RegExp("youtube.com|.google.|.google.com|greasyfork.org|twitter.com|instagram.com|facebook.com|translate.google.com|.amazon.|.ebay.|github.|stackoverflow.com|bing.com|live.com|.microsoft.com|dropbox.com|pcloud.com|box.com|sync.com|onedrive.com|mail.ru|deviantart.com|pastebin.com|dailymotion.com|twitch.tv|spotify.com|steam.com|steampowered.com|gitlab.com|.reddit.com").exec(window.location.hostname);window&&null!=n&&(i=function(){this.h=["DOMAttrModified","DOMNodeInserted","DOMNodeRemoved","DOMCharacterDataModified","DOMSubtreeModified"],this.bind()},s=function(t){this.event=t,this.g=this.createEvent(this.event.type)},a||1==r||(o=document,a=document.body,o.oncontextmenu=null,o.onselectstart=null,o.ondragstart=null,o.onmousedown=null,a.oncontextmenu=null,a.onselectstart=null,a.ondragstart=null,a.onmousedown=null,a.oncut=null,a.oncopy=null,a.onpaste=null,[].forEach.call(["copy","cut","paste","select","selectstart"],function(t){document.addEventListener(t,function(t){t.stopPropagation()},!0)}),RegExp("example.com|www.example.com").exec(location.hostname)&&e(),function(){try{GM_registerMenuCommand("Enable Absolute Right Click Mode",function(){return 1==confirm("Activate Absolute Right Click Mode!")?e():null})}catch(t){console.log(t)}}(),n.appendChild(t),document.addEventListener("keydown",function(t){if(t.ctrlKey&&192==t.keyCode)return 1==confirm("Activate Absolute Right Click Mode!")?e():null}),r=!0,window.addEventListener("contextmenu",function t(e){e.stopPropagation(),e.stopImmediatePropagation();var n=new s(e);window.removeEventListener(e.type,t,!0);var o=new i;n.i(),window.addEventListener(e.type,t,!0),n.l&&o.j&&e.preventDefault()},!0)),i.prototype.bind=function(){this.h.forEach(function(t){document.addEventListener(t,this,!0)}.bind(this))},i.prototype.handleEvent=function(){this.j=!0},s.prototype.createEvent=function(t){var e=this.event.target,n=e.ownerDocument.createEvent("MouseEvents");return n.initMouseEvent(t,this.event.bubbles,this.event.cancelable,e.ownerDocument.defaultView,this.event.detail,this.event.screenX,this.event.screenY,this.event.clientX,this.event.clientY,this.event.ctrlKey,this.event.altKey,this.event.shiftKey,this.event.metaKey,this.event.button,this.event.relatedTarget),n},s.prototype.i=function(){var t=this.event.target;(function(t){t.preventDefault()}).bind(this),t.dispatchEvent(this.g),this.l=this.g.defaultPrevented})}(),function(t){for(var e,n="contextmenu copy cut paste mousedown mouseup beforeunload beforeprint".split(" "),o=0;e=n[o];o++)t["on"+e]&&(t["on"+e]=null),t.addEventListener(e,function(t){t.stopPropagation()},!0);for(n=0;e=t.frames[n];n++)try{arguments.callee(e)}catch(t){}}(window),function(){function r(){this.s=this.m=!1,this.l=["DOMAttrModified","DOMNodeInserted","DOMNodeRemoved","DOMCharacterDataModified","DOMSubtreeModified"],this.bind()}function a(){this.A=window.setTimeout,this.v=window.requestAnimationFrame,this.g=window.Promise,this.h=this.o=!1,window.requestAnimationFrame=window.setTimeout=function(t){t()},window.Promise=function(){this.g.apply(this,arguments),this.h=!0,window.Promise=this.g}}function c(t){this.event=t,this.i=this.createEvent(this.event.type),this.C=this.createEvent("mouseup"),this.j=this.i.defaultPrevented}r.prototype.bind=function(){this.l.forEach(function(t){document.addEventListener(t,this,!0)}.bind(this))},r.prototype.handleEvent=function(){this.m=!0,this.u()},r.prototype.u=function(){this.s||(this.l.forEach(function(t){document.removeEventListener(t,this,!0)}.bind(this)),this.s=!0)},a.prototype.restore=function(){this.o||(window.setTimeout=this.A,window.requestAnimationFrame=this.v,this.h||(window.Promise=this.g),this.o=!0)},c.prototype.createEvent=function(t){var e=this.event.target,n=e.ownerDocument.createEvent("MouseEvents");return n.initMouseEvent(t,this.event.bubbles,this.event.cancelable,e.ownerDocument.defaultView,this.event.detail,this.event.screenX,this.event.screenY,this.event.clientX,this.event.clientY,this.event.ctrlKey,this.event.altKey,this.event.shiftKey,this.event.metaKey,this.event.button,this.event.relatedTarget),n};var d=!(c.prototype.B=function(){var t=this.event.target,e=function(t){this.j=t.defaultPrevented,t.preventDefault()}.bind(this);window.addEventListener(this.event.type,e,!1),t.dispatchEvent(this.i),window.removeEventListener(this.event.type,e,!1),this.j=this.i.defaultPrevented,t.dispatchEvent(this.C)});window.addEventListener("message",function(t){t.data&&"enable-right-click"===t.data.type&&(d=!!t.data.D,t.stopPropagation(),t.stopImmediatePropagation())},!0),window.addEventListener("contextmenu",function t(e){var n,o,i,s;d||(e.stopPropagation(),e.stopImmediatePropagation(),n=new c(e),window.removeEventListener(e.type,t,!0),o=new a,i=new r,s=window.alert,window.alert=function(){},n.B(),window.alert=s,o.restore(),i.u(),window.addEventListener(e.type,t,!0),n.j&&(i.m||o.h)&&e.preventDefault())},!0)}(),function(t){for(var e,n="contextmenu copy cut paste mousedown mouseup beforeunload beforeprint".split(" "),o=0;e=n[o];o++)t["on"+e]&&(t["on"+e]=null),t.addEventListener(e,function(t){t.stopPropagation()},!0);for(n=0;e=t.frames[n];n++)try{arguments.callee(e)}catch(t){}}(window);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PART ONE [minified]