Prevent contextmenu hijack

Removes all listeners to the contextmenu event

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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);