Prevent contextmenu hijack

Removes all listeners to the contextmenu event

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Prevent contextmenu hijack
// @namespace    http://github.com/kba
// @version      0.1
// @description  Removes all listeners to the contextmenu event
// @author       kba
// @match        */*
// @grant        GM_registerMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// ==/UserScript==
/* jshint -W097 */
/* globals GM_getValue, GM_setValue, GM_registerMenuCommand */
'use strict';


function removeContextMenuListeners() {
	document.oncontextmenu = null;
	var elems = document.querySelectorAll('div,img,video,figure,main,article,section,header,footer');
	for (var i = 0 ; i < elems.length ; i++) {
		elems[i].oncontextmenu = null;
	}
}

function isPermanent() { return GM_getValue('permanent'); }
function togglePermanent() { GM_setValue('permanent', ! isPermanent()); }

if (isPermanent()) {
	setTimeout(removeContextMenuListeners, 500);
}

GM_registerMenuCommand('Allow Right-Click', removeContextMenuListeners);
GM_registerMenuCommand((isPermanent() ? 'Dis' : 'En') +  'able Permanent Allow Right-Click', togglePermanent);