360搜索真实链接地址重定向

搜索结果链接修正,直接跳转至目标网址,而不经过中间的二次跳转页面

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name                Link Redirect Fix for 360so
// @name:zh-CN          360搜索真实链接地址重定向
// @name:zh-TW          360搜索真實鏈接地址重定向
// @description         Avoid link redirect for 360 search
// @description:zh-CN   搜索结果链接修正,直接跳转至目标网址,而不经过中间的二次跳转页面
// @description:zh-TW   搜索結果鏈接修正,直接跳轉至目標網址,而不經過中間的二次跳轉頁面

// @author              Moshel
// @namespace           https://hzy.pw
// @homepageURL         https://hzy.pw/p/2056
// @supportURL          https://github.com/h2y/link-fix
// @license             GPL-3.0
// @icon                https://p.ssl.qhimg.com/t011a6c04685b5d3b80.png

// @grant               none
// @run-at              document-end
// @include             https://www.so.com/s?*

// @date                06/09/2016
// @modified            08/07/2016
// @version             1.0.1.1
// ==/UserScript==


!function() {

    var dom = null;
    function ajax_fixer() {
        var new_dom = document.querySelector('#m-result');
        if (new_dom && new_dom !== dom) {
            dom = new_dom;
            main();
        }
        setTimeout(ajax_fixer, 2222);
    }
    ajax_fixer();


    function main() {
        var num = 0,
            as = dom.querySelectorAll('a');
        for(var i=0; i<as.length; i++) {
            var old = as[i].href.match(/url=(.+?)(&|$)/);
            if(old && old.length>=2) {
                as[i].href = decodeURIComponent(old[1]);
                num++;
            }
        }
        if(num)
            console.log(num+' 条链接已重定向至真实地址');
    }

}();