Unlock Website Limit

Unlock website events, including right click, selection lock, copy and cut, etc.

当前为 2025-03-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name               Unlock Website Limit
// @name:zh-TW         解鎖網頁事件
// @namespace          https://github.snkms.com/
// @version            0.8
// @description        Unlock website events, including right click, selection lock, copy and cut, etc.
// @description:zh-TW  使用Javascript解除部分網頁事件,包括鎖右鍵、鎖複製等等
// @author             SN-Koarashi (5026)
// @match              *://*/*
// @grant              none
// @supportURL         https://discord.gg/q3KT4hdq8x
// @license            MIT
// ==/UserScript==

(function() {
    'use strict';
    function unBlockFunc(eventName) {
        var onData = "on" + eventName;
        if (window.addEventListener) {
            window.addEventListener(eventName, function(e) {
                for (var n = e.target; n; n = n.parentNode){
                    n[onData] = null;
                }
            }, true);
        }
        window[onData] = null;
        document[onData] = null;
        if (document.documentElement) document.documentElement[onData] = null;
        if (document.body) document.body[onData] = null;
        document.body.oncopy = null;
    }

    function ObjectLength(object) {
        var length = 0;
        for (var key in object) {
            if (object.hasOwnProperty(key)) {
                length++;
            }
        }
        return length;
    };

    document.addEventListener("DOMContentLoaded", function() {
        var hookEvents = {
            0: "contextmenu",
            1: "click",
            2: "mousedown",
            3: "mouseup",
            4: "keydown",
            5: "keyup",
            6: "selectstart",
            7: "select",
            8: "copy",
            9: "cut",
            10: "dragstart"
        };

        for (var i = 0; i < ObjectLength(hookEvents); i++) {
            unBlockFunc(hookEvents[i]);
        }

        var css = document.createElement("style");
        var style = document.createTextNode("*{-ms-user-select: auto !important;-moz-user-select: auto !important;-webkit-user-select: auto !important;user-select: auto !important;}");

        css.appendChild(style);
        document.body.appendChild(css);
    });
})();