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);

  • 相关阅读:
    点击空白处隐藏盒子
    java缓存技术
    使用Java处理大文件
    java实现把一个大文件切割成N个固定大小的文件
    笔记:Java的IO性能调整
    NIO之轻松读取大文件
    java读写文件,读超大文件
    java读取大文件 超大文件的几种方法
    java web服务器cpu占用过高的处理
    软件开发各类文档模板
  • 原文地址:https://www.cnblogs.com/zeroone/p/2729117.html
Copyright © 2011-2022 走看看