6

I'm using a website that uses the following code in their html source (as discussed here on Stack Overflow), as a way to disable right-clicking on the web page:

<body oncontextmenu="return false;">

I am assuming the easiest way to permanently and automatically bypass it (using Chrome or Firefox) - without turning off javascript altogether - is to create a simple userscript to remove this string of html code from the page (as doing so with Developer tools confirms it removes the restriction), so in the userscript effectively have it replace this string:

 oncontextmenu="return false;"

with nothing - no characters as its replacement.

Is this the best way to bypass this restriction without turning off javascript entirely (including other actually useful scripts on the domain), and if so what would be the code to do it?

1 Answers1

3

In Firefox, open about:config and set dom.event.contextmenu.enabled to false. That should take care of it for all websites, but it also disables some right-click features that a very few websites add.

Otherwise, the userscript for this particular website appears to be dirt simple. Here's the complete script:

// ==UserScript==
// @name     _Stop contextmenu vandalism
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// ==/UserScript==

document.body.removeAttribute ("oncontextmenu");

Just adjust YOUR_SERVER.COM/YOUR_PATH as needed.

Brock Adams
  • 2,200