解鎖網頁事件

使用Javascript解除部分網頁事件,包括鎖右鍵、鎖複製等等

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址