zoukankan      html  css  js  c++  java
  • 禁止firefox 重定向脚本 武胜

    // ==UserScript==
    // @name           Google direct Link
    // @namespace      http://userscripts.org/users/tommy
    // @author         .
    // @description    remove google search and image link redirection to speed up your browsing and hide referrer
    // @include        *.google.*/*
    // @version        0.0.5
    // @run-at         document-start
    // ==/UserScript==


    var hideReferer = true,
        newTab = true,
        showCache = false;

    var ua = navigator.userAgent,
        wK = ua.toLowerCase().indexOf('webkit') > -1,
        S = location.protocol === 'https:';

    function addEvent(a, b, c) {
        if (a.addEventListener) {
            a.addEventListener(b, c, false);
        }
    }

    function removeEvent(a, b, c) {
        if (a.removeEventListener) {
            a.removeEventListener(b, c, false);
        }
    }

    if (Object.defineProperty) {
        Object.defineProperty(window, 'rwt', {
            value: function() {},
            writable: false,
            configurable: false
        })
    } else {
        window.__defineGetter__('rwt', function() {
            return function() {}
        })
    }

    if (showCache) {
        addEvent(window, 'DOMNodeInserted', cache);
    }

    function cache() {
        var cc = document.querySelectorAll('.vshid');
        if (cc) {
            for (var i = 0; i < cc.length; ++i) {
                cc[i].style.display = 'inline';
            }
        }
    }

    function proxy(e) {
        if (e && e.localName == 'a' && (e.className == 'l' || e.className == 'rg_l' || e.parentNode.className == 'vshid' || e.parentNode.className == 'gl')) {
            var m = /&imgurl=([^&]+)/.exec(e.href);
            if (m) e.href = m[1];
            if (newTab) e.target = "_blank";
            if (hideReferer) {
                if (wK) {
                    e.rel = "noreferrer";
                } else if (!S && e.href.indexOf('http-equiv="refresh"') == -1) {
                    e.href = 'data:text/html, <meta http-equiv="refresh" content="0;URL=' + encodeURIComponent(e.href) + '" charset="utf-8">';
                }
            }
        }
    }

    function doStuff(e) {
        var a = e.target;
        if (a.localName != 'a') {
            for (; a; a = a.parentNode){
                proxy(a);
            }
        } else {
            proxy(a);
        }
    }

    addEvent(window, "mousedown", doStuff);

  • 相关阅读:
    【leetcode】1009. 十进制整数的反码
    【leetcode】1446. 连续字符
    __getattr__在python2.x与python3.x中的区别及其对属性截取与代理类的影响
    Python 中异常嵌套
    python 变量搜寻顺序法则LEGB之E注意事项
    %%的一个应用
    python中__str__与__repr__
    052-180
    052-177
    052-176
  • 原文地址:https://www.cnblogs.com/zeroone/p/2729117.html
Copyright © 2011-2022 走看看