Skip to content

Instantly share code, notes, and snippets.

@vaaas
Last active May 20, 2024 12:31
Show Gist options
  • Save vaaas/99fa14394d2c7329a06b9e103e4f12f2 to your computer and use it in GitHub Desktop.
Save vaaas/99fa14394d2c7329a06b9e103e4f12f2 to your computer and use it in GitHub Desktop.
Disable context menu highjacking
// ==UserScript==
// @name Disable context menu highjacking
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Disables context menu event highjacking
// @author Vasileios Pasialiokis
// @match https://www.redgifs.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict'
const original = EventTarget.prototype.addEventListener;
function replacement(...xs) {
if (xs[0] === 'contextmenu')
return console.log('prevented context menu highjacking');
else
return original.apply(this, xs);
}
EventTarget.prototype.addEventListener = replacement;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment