Absolute Enable Right Click & Copy

Force Enable right click & Copy & Highlight

As of 2016-10-27. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Absolute Enable Right Click & Copy
// @namespace    Absolute Right Click
// @description  Force Enable right click & Copy & Highlight
// @author       Absolute
// @version      1.2.3
// @include      http*://*
// @icon         https://cdn3.iconfinder.com/data/icons/communication-130/63/cursor-128.png
// @license      BSD
// @copyright    Absolute
// @grant        GM_addStyle
// @Exclude      /.*(JPG|PNG|GIF|JPEG|ico|bing|facebook|google|pixiv).*/

// ==/UserScript==

    var Sites_List =  ['163.com','www.site.com','www.site.com','www.site.com','www.site.com'];

    (function GetSelection () {
		var style  = document.createElement('style');
		var iStyle = '*{user-select: text !important;-webkit-user-select:text!important;}';
		style.type = 'text/css';
     	if (style.styleSheet) { style.styleSheet.cssText = iStyle; }
		else { style.appendChild(document.createTextNode(iStyle)); }
		window.getSelection = null;
		document.oncontextmenu = null;
		document.body.setAttribute('oncopy','null');
		document.body.setAttribute('oncut','null');
		document.getElementsByTagName('head')[0].appendChild(style);
        })();

    function Check (event) {
		if (event.stopPropagation) {
		event.stopPropagation();
		}}
        var events = ['NO-contextmenu','selectstart'];
        for (var i = 0; i < events.length; i++) {
      	document['on'+events[i]] = Check;
        document.addEventListener(events[i], Check, true, true);
		}

   (function RightClickButton() {
        function Mutation (callback) {
        this.isCalled = false;
        this.isUnbound = false;
        this.callback = callback;
        this.events = ['DOMAttrModified', 'DOMNodeInserted', 'DOMNodeRemoved', 'DOMCharacterDataModified', 'DOMSubtreeModified'];
        this.bind();
		}
    Mutation.prototype.bind = function () {
        this.events.forEach(function (name) {
        document.addEventListener(name, this, true);
		}.bind(this));
        };
    Mutation.prototype.handleEvent = function () {
        this.isCalled = true;
        this.unbind();
        };
    Mutation.prototype.unbind = function () {
		if (this.isUnbound) {
        return;
        }
    this.events.forEach(function (name) {
		document.removeEventListener(name, this, true);
        }.bind(this));
		this.isUnbound = true;
        };
    function Synchronizetion () {
        this._setTimeout = window.setTimeout;
        this._requestAnimationFrame = window.requestAnimationFrame;
        this._Promise = window.Promise;
        this.isRestoration = false;
        this.calledPromise = false;
        window.requestAnimationFrame = window.setTimeout = function (callback) {
        callback();
        };
    window.Promise = function () {
		this._Promise.apply(this, arguments);
		this.calledPromise = true;
		window.Promise = this._Promise;
        };}
    Synchronizetion.prototype.restore = function () {
        if (this.isRestoration) { return; }
		window.setTimeout = this._setTimeout;
		window.requestAnimationFrame = this._requestAnimationFrame;
        if (!this.calledPromise) {
	    window.Promise = this._Promise;
        }
        this.isRestoration = true;
        };
    function EventHandler (event) {
        this.event = event;
        this.contextmenuEvent = this.createEvent(this.event.type);
        this.mouseupEvent = this.createEvent('mouseup');
        this.isCanceled = this.contextmenuEvent.defaultPrevented;
        }
    EventHandler.prototype.createEvent = function (type) {
		var target = this.event.target;
		var event = target.ownerDocument.createEvent('MouseEvents');
		event.initMouseEvent(type, this.event.bubbles, this.event.cancelable,
        target.ownerDocument.defaultView, this.event.detail,
   	    this.event.screenX, this.event.screenY, this.event.clientX, this.event.clientY,
        this.event.ctrlKey, this.event.altKey, this.event.shiftKey, this.event.metaKey,
        this.event.button, this.event.relatedTarget
        );return event;
        };
    EventHandler.prototype.fire = function () {
        var target = this.event.target;
        var contextmenuHandler = function (event) {
	    this.isCanceled = event.defaultPrevented;
        event.preventDefault();
        }.bind(this);
    window.addEventListener(this.event.type, contextmenuHandler, false);
        target.dispatchEvent(this.contextmenuEvent);
        window.removeEventListener(this.event.type, contextmenuHandler, false);
        this.isCanceled = this.contextmenuEvent.defaultPrevented;
        target.dispatchEvent(this.mouseupEvent);
        };
    var disableRightClick = false;
	    window.addEventListener('message', function (event) {
        if (event.data.type !== 'enable-right-click') { return; }
        disableRightClick = !!event.data.disableRightClick;
        event.stopPropagation();
        event.stopImmediatePropagation();
        }, true);
        window.addEventListener('contextmenu', handleEvent, true);
    function handleEvent (event) {
		if (disableRightClick) { return; }
		event.stopPropagation();
        event.stopImmediatePropagation();
        var handler = new EventHandler(event);
		window.removeEventListener(event.type, handleEvent, true);
        var sync = new Synchronizetion();
        var mutation = new Mutation(function () {
	    sync.restore(); });
    var _alert = window.alert;
        window.alert = function () {};
        handler.fire();
        window.alert = _alert;
        sync.restore();
        mutation.unbind();
        window.addEventListener(event.type, handleEvent, true);
        if (handler.isCanceled && (mutation.isCalled || sync.calledPromise)) {
        event.preventDefault();
		}}})();

    (function CheckSites () {
		var Check = window.location.href;
		var Match = RegExp(Sites_List.join('|')).exec(Check);
		if (Match) { Absolute_Mod (); }})();

    function KeyPress (e) {
		if (e.altKey && e.ctrlKey) {
	    alert("Absolute Right Click Mod Activate !!!");
		Absolute_Mod();}}
        document.addEventListener("keydown", KeyPress);

    function Absolute_Mod () {
		document.addEventListener("copy",function(e){e.stopPropagation();},true);
		document.addEventListener("keyup",function(e){e.stopPropagation();},true);
		document.addEventListener("mouseup",function(e){e.stopPropagation();},true);
		document.addEventListener("keydown",function(e){e.stopPropagation();},true);
		document.addEventListener("mousedown",function(e){e.stopPropagation();},true);
		document.addEventListener("dragstart",function(e){e.stopPropagation();},true);
		document.addEventListener("mousedown",function(e) {e.stopPropagation();},true);
		document.addEventListener("contextmenu",function(e){e.stopPropagation();},true);
		document.addEventListener("selectstart",function(e){e.stopPropagation();},true);
	    }