Skip to content

Instantly share code, notes, and snippets.

@amblerkr
Last active October 8, 2022 01:47
Show Gist options
  • Select an option

  • Save amblerkr/7f065339f87563c9d4afcfd456760b0a to your computer and use it in GitHub Desktop.

Select an option

Save amblerkr/7f065339f87563c9d4afcfd456760b0a to your computer and use it in GitHub Desktop.

Revisions

  1. amblerkr revised this gist Jan 10, 2021. 2 changed files with 0 additions and 0 deletions.
  2. amblerkr revised this gist Jan 10, 2021. 1 changed file with 186 additions and 0 deletions.
    186 changes: 186 additions & 0 deletions Absolute_Enable_Right_Click.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,186 @@
    // ==UserScript==
    // @name Absolute Enable Right Click & Copy
    // @namespace Absolute Right Click
    // @description Force Enable Right Click & Copy & Highlight
    // @shortcutKeys [Ctrl + `] Activate Absolute Right Click Mode To Force Remove Any Type Of Protection
    // @author Absolute
    // @version 1.8.9
    // @include *://*
    // @icon https://i.imgur.com/AC7SyUr.png
    // @compatible Chrome Google Chrome + Tampermonkey
    // @grant GM_registerMenuCommand
    // @license BSD
    // @copyright Absolute, 2016-Oct-06
    // ==/UserScript==

    (function() {
    'use strict';

    var css = document.createElement('style');
    var head = document.head;

    css.type = 'text/css';

    css.innerText = `* {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    }`;

    function main() {

    var doc = document;
    var body = document.body;

    var docEvents = [
    doc.oncontextmenu = null,
    doc.onselectstart = null,
    doc.ondragstart = null,
    doc.onmousedown = null
    ];

    var bodyEvents = [
    body.oncontextmenu = null,
    body.onselectstart = null,
    body.ondragstart = null,
    body.onmousedown = null,
    body.oncut = null,
    body.oncopy = null,
    body.onpaste = null
    ];

    [].forEach.call(
    ['copy', 'cut', 'paste', 'select', 'selectstart'],
    function(event) {
    document.addEventListener(event, function(e) { e.stopPropagation(); }, true);
    }
    );

    alwaysAbsoluteMode();
    enableCommandMenu();
    head.appendChild(css);
    document.addEventListener('keydown', keyPress);
    }

    function keyPress(event) {
    if (event.ctrlKey && event.keyCode == 192) {
    return confirm('Activate Absolute Right Click Mode!') == true ? absoluteMode() : null;
    }
    }

    function absoluteMode() {
    [].forEach.call(
    ['contextmenu', 'copy', 'cut', 'paste', 'mouseup', 'mousedown', 'keyup', 'keydown', 'drag', 'dragstart', 'select', 'selectstart'],
    function(event) {
    document.addEventListener(event, function(e) { e.stopPropagation(); }, true);
    }
    );
    }

    function alwaysAbsoluteMode() {
    let sites = ['example.com','www.example.com'];
    const list = RegExp(sites.join('|')).exec(location.hostname);
    return list ? absoluteMode() : null;
    }

    function enableCommandMenu() {
    var commandMenu = true;
    try {
    if (typeof(GM_registerMenuCommand) == undefined) {
    return;
    } else {
    if (commandMenu == true ) {
    GM_registerMenuCommand('Enable Absolute Right Click Mode', function() {
    return confirm('Activate Absolute Right Click Mode!') == true ? absoluteMode() : null;
    });
    }
    }
    }
    catch(err) {
    console.log(err);
    }
    }

    var blackList = [
    'youtube.com','.google.','.google.com','greasyfork.org','twitter.com','instagram.com','facebook.com','translate.google.com','.amazon.','.ebay.','github.','stackoverflow.com',
    'bing.com','live.com','.microsoft.com','dropbox.com','pcloud.com','box.com','sync.com','onedrive.com','mail.ru','deviantart.com','pastebin.com',
    'dailymotion.com','twitch.tv','spotify.com','steam.com','steampowered.com','gitlab.com','.reddit.com'
    ]

    var enabled = false;
    var url = window.location.hostname;
    var match = RegExp(blackList.join('|')).exec(url);

    if (window && typeof window != undefined && head != undefined) {

    if (!match && enabled != true) {

    main();
    enabled = true

    //console.log(location.hostname);

    window.addEventListener('contextmenu', function contextmenu(event) {
    event.stopPropagation();
    event.stopImmediatePropagation();
    var handler = new eventHandler(event);
    window.removeEventListener(event.type, contextmenu, true);
    var eventsCallBack = new eventsCall(function() {});
    handler.fire();
    window.addEventListener(event.type, contextmenu, true);
    if (handler.isCanceled && (eventsCallBack.isCalled)) {
    event.preventDefault();
    }
    }, true);
    }

    function eventsCall() {
    this.events = ['DOMAttrModified', 'DOMNodeInserted', 'DOMNodeRemoved', 'DOMCharacterDataModified', 'DOMSubtreeModified'];
    this.bind();
    }

    eventsCall.prototype.bind = function() {
    this.events.forEach(function (event) {
    document.addEventListener(event, this, true);
    }.bind(this));
    };

    eventsCall.prototype.handleEvent = function() {
    this.isCalled = true;
    };

    eventsCall.prototype.unbind = function() {
    this.events.forEach(function (event) {}.bind(this));
    };

    function eventHandler(event) {
    this.event = event;
    this.contextmenuEvent = this.createEvent(this.event.type);
    }

    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) {
    event.preventDefault();
    }.bind(this);
    target.dispatchEvent(this.contextmenuEvent);
    this.isCanceled = this.contextmenuEvent.defaultPrevented;
    };

    }

    })();
  3. amblerkr revised this gist Jan 10, 2021. 1 changed file with 81 additions and 0 deletions.
    81 changes: 81 additions & 0 deletions Anti-Disabler_for_Naver.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,81 @@
    // ==UserScript==
    // @name Anti-Disabler for Naver
    // @namespace https://userscripts-mirror.org/users/dyhan81
    // @description The script allows users to call the context menu or select the texts in Naver, and when you copy text, script will get rid of a annoying source indication.
    // @include http://blog.naver.com/*
    // @include http://cafe.naver.com/*
    // @copyright 2009+, Dong-yoon Han (http://cb-dyhan81.blogspot.com)
    // @license (CC) Attribution Non-Commercial Share Alike; http://creativecommons.org/licenses/by-nc-sa/2.0/kr/
    // @version 1258306524556; Mon Nov 16 2009 02:35:24 GMT+0900
    // @injectframes 1
    // ==/UserScript==

    (function(){

    var intervalID;
    var domain = window.location.host;

    // For Blog
    if (domain.toLowerCase().indexOf("blog.")>-1)
    {
    intervalID = setInterval(" \
    if(window.AutoSourcing != null) \
    { \
    AutoSourcing.setEnable(false); \
    } \
    \
    if(window.utility != null) \
    { \
    utility.detachSelectPrevent(); \
    } \
    ", 500);
    setTimeout("clearInterval("+intervalID+");", 3000);
    }

    /* For Cafe */
    if (domain.toLowerCase().indexOf("cafe.")>-1)
    {
    intervalID = setInterval(" \
    if(window.AutoSourcing != null) \
    AutoSourcing.setEnable(false); \
    \
    var alternativeCancelBlockMouseRight = function(theElement) \
    { \
    var trueFunc = function() \
    { \
    return true; \
    }; \
    \
    theElement.oncontextmenu = trueFunc; \
    theElement.onselectstart = trueFunc; \
    theElement.ondragstart = trueFunc; \
    }; \
    \
    if(window.CancelBlockMouseRight != null) \
    { \
    CancelBlockMouseRight(); \
    cancelBlockDragInFF(); \
    } \
    \
    if(window.mlayoutPhoto != null) \
    { \
    alternativeCancelBlockMouseRight(parent.document); \
    alternativeCancelBlockMouseRight(window.mlayoutPhoto.oView); \
    window.mlayoutPhoto.opt.allowRightMouseClick = true; \
    } \
    ",500);
    setTimeout("clearInterval("+intervalID+");", 3000);

    intervalID = setInterval(" \
    if( document.getElementById('content-area') \
    && (document.getElementById('content-area').oncontextmenu != null))\
    { \
    document.getElementById('content-area').oncontextmenu = null; \
    document.getElementById('content-area').onselectstart = null; \
    document.getElementById('content-area').ondragstart = null; \
    } \
    ", 500);
    setTimeout("clearInterval("+intervalID+");", 3000);
    }

    })();
  4. amblerkr revised this gist Dec 12, 2020. 2 changed files with 0 additions and 0 deletions.
  5. amblerkr revised this gist Dec 12, 2020. 2 changed files with 0 additions and 0 deletions.
  6. amblerkr renamed this gist Dec 12, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. amblerkr created this gist Dec 12, 2020.
    1 change: 1 addition & 0 deletions 네이버 우클릭 해제 1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    javascript:{function unify(d){try{d.oncontextmenu = null;d.onselectstart = null;d.ondragstart = null;d.onkeydown = null;d.onmousedown = null;d.body.oncontextmenu = null;d.body.onselectstart = null;d.body.ondragstart = null;d.body.onkeydown = null;d.body.onmousedown = null;}catch(e){};if (d.frames.length > 0) {for (var i = 0; i < d.frames.length; i++) {try {unify(d.frames[i]);} catch (e) {}};};for(i in document.getElementsByTagName("div")){try{unify(document.getElementsByTagName("div")[i]);}catch(e) {};}}unify(self);var domain = document.URL;if (domain.toLowerCase().indexOf('blog.') > -1) {document.getElementById('mainFrame').contentDocument.getElementById('photoviewer').draggable = true;document.getElementById('mainFrame').contentDocument.papermain.utility.detachSelectPrevent();}if (domain.toLowerCase().indexOf('cafe.') > -1) {document.getElementById('cafe_main').contentDocument.oncontextmenu = null;document.getElementById('cafe_main').contentDocument.ondragstart = null;document.getElementById('cafe_main').contentDocument.onselectstart = null;document.getElementById('cafe_main').contentDocument.photoViewerFrm.draggable = true;}alert('해제되었습니다.');}
    1 change: 1 addition & 0 deletions 네이버 우클릭 해제 2
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    javascript: function naver(q){ void(z=q.body.appendChild(q.createElement('script'))); void(z.language='javascript'); void(z.type='text/javascript'); void(z.src='https://greasyfork.org/scripts/23772-absolute-enable-right-click-copy/code/Absolute%20Enable%20Right%20Click%20%20Copy.user.js');} function selfw(w) { try{naver(w.document);} catch(e){} for (var i =0; i <w.frames.length; i++) { try{ selfw(w.frames[i]); } catch(e){} } } selfw(self);(function() { var e, i, all; document.onselectstart = null; document.oncontextmenu = null; all = document.getElementsByTagName("*"); for (i = 0; i < all.length; i += 1) { e = all[i]; e.onselectstart = null; e.oncontextmenu = null; } })();