解鎖網頁事件

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

目前為 2020-06-16 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(function() {
    'use strict';

    var $ = window.jQuery;
    function unBlockFunc(a) {
        var onData = "on" + a;
        if (window.addEventListener) {
            window.addEventListener(a, function(e) {
                for (var n = e.originalTarget; 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;
    };
    $(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);
    });
})();