全部読む 最新50 1-100 掲示板トップ

スマホの長押し禁止を解除・回避するJavaScriptコード

  • 1 名前: 名無し 2021-10-13 04:08:45 ID:4NmRmMTZh

    // ==UserScript==
    // @name Anti-NoCopy
    // @version 0.1.0
    // @description
    // ==/UserScript==
    ! function() {
    var a = document,
    b = ["userSelect", "khtmlUserSelect", "MozUserSelect", "MsUserSelect", "WebkitUserSelect"];
    f = function() {
    return true;
    };
    Array.prototype.forEach.call(a.all, function(a) {
    a.style &&
    b.forEach(function(b) {
    a.style[b] = "auto"
    }), a.onmousedown = a.onmousemove = a.onmouseup = a.onselectstart = ""
    }), a.onmousedown = a.onmousemove = a.onmouseup = a.onselectstart = a.oncontextmenu = a.body.oncontextmenu = f;
    obs = document.all;
    for (i = 0; i < obs.length; i++) {
    obs[i].oncontextmenu = 'return true;';
    obs[i].onselectstart = 'return true;';
    }
    }();

  • 2 名前: 名無し 2021-10-13 07:26:51 ID:wNjJjMWE1

    >>1のコードが効かない場合

    document.addEventListener('contextmenu',function(e){e.stopPropagation();},true);

  • 3 名前: 名無し 2021-10-13 07:32:35 ID:wNjJjMWE1

    ◯右クリック、テキスト選択禁止を解除
    javascript:(function(){
    var d = document;
    var select = ['userSelect','khtmlUserSelect','MozUserSelect','MsUserSelect','WebkitUserSelect'];
    Array.prototype.forEach.call(d.all, function(el){
    if(el.style) select.forEach(function(style){el.style[style] = 'auto';});
    el.onmousedown = el.onmousemove = el.onmouseup = el.onselectstart = '';
    });
    d.onmousedown = d.onmousemove = d.onmouseup = d.onselectstart = d.oncontextmenu = d.body.oncontextmenu = '';
    })()

    https://medaka.5ch.net/test/read.cgi/shop/1571749537/253


全部読む 最新50 1-100 掲示板トップ s



This site is protected by reCAPTCHA and the GooglePrivacy Policy andTerms of Service apply.