您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Removes all listeners to the contextmenu event
当前为
- // ==UserScript==
- // @name Allow Right Click
- // @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);