Anti Right-Click Hijaak

Prevent websites from changing or preventing your right click menu

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Anti Right-Click Hijaak
// @version      0.3
// @description  Prevent websites from changing or preventing your right click menu
// @grant        GM_registerMenuCommand
// @run-at       document-start
// @match        *://*/*
// @license      MIT
// @namespace https://greasyfork.org/users/1253611
// ==/UserScript==
GM_registerMenuCommand("Include Current Site", includeSite);
GM_registerMenuCommand("Exclude Current Site", excludeSite);
if (localStorage.getItem("included") === window.location.hostname) {
    // Add event listeners only if the conditions are met
    document.addEventListener("copy", (event) => { event.stopImmediatePropagation(); }, true);
    document.addEventListener("paste", (event) => { event.stopImmediatePropagation(); }, true);
    document.addEventListener("contextmenu", (event) => { event.stopImmediatePropagation(); }, true);
}


function includeSite() {
    localStorage.setItem("included", window.location.hostname); // Change "included" to something else if multiple userscripts use this code
}

function excludeSite() {
    localStorage.removeItem("included", window.location.hostname);
}