// ==UserScript== // @name AC-baidu: 优化百度、搜狗、谷歌搜索结果之重定向 lite // @icon https://coding.net/u/zb227/p/zbImg/git/raw/master/img0/icon.jpg // @grant GM_xmlhttpRequest // @author AC // @create 2015-11-25 // @run-at document-start // @version 9.4 // @connect * // @include http://www.baidu.com/* // @include https://www.baidu.com/* // @include http://www.sogou.com/* // @include https://www.sogou.com/* // @include /^https?\:\/\/encrypted.google.[^\/]+/ // @include /^https?\:\/\/www.google.[^\/]+/ // @include https://*.zhidao.baidu.com/* // @include https://zhidao.baidu.com/* // @home-url https://greasyfork.org/zh-TW/scripts/14178 // @namespace 1353464539@qq.com // @copyright 2017, AC // @description 繞過百度、搜狗搜索結果中的自己的跳轉鏈接,直接訪問原始網頁-反正都能看懂 // @lastmodified 2017-05-26 // @feedback-url https://greasyfork.org/zh-TW/scripts/14178 // @note 2017.05.26-V9.4 只是移除百度的重定向问题,其他不做处理,不包含去广告,不添加favicon // @downloadURL none // ==/UserScript== // 采用MutationObserver监视会大大实际代码的调用次数-比DOMNodeInserted更好的调用方式,但是百度已经移除了Mo,所以继续用Dom吧,以后来改 (function(){ var fatherName = new Array( "c-container", //baidu1 "rc", //google "b_algo", //bing1 "b_ans", //bing2 "vrwrap", //sogou1 "rb"//sogou2 ); var Stype; // 去重定向的选择 var Ftype; // favicon的选择 if (location.host == "www.baidu.com") { Stype = "h3.t>a"; Ftype = ".f13 .c-showurl[href],.c-container>div[class^='c-'] .c-showurl[href],.c-container>div[class^='c-'] .texttolink[href]"; } else if (location.host == "sogou.com") { Stype = "h3.pt>a, h3.vrTitle>a"; Ftype = "cite[id*='cacheresult_info_']"; } else if (location.host.indexOf("google") > -1){ Stype = "h3>a"; Ftype = "._Rm"; } else { addStyle(".word-replace{display: none !important;}"); return; } document.addEventListener("DOMNodeInserted", function(event){ var element = event.target; removeOnMouseDownFunc(); resetURL(document.querySelectorAll(Stype)); }); function removeOnMouseDownFunc(){ try{ var nodes = document.querySelectorAll(".g .rc .r a"); for(var i=0; i -1 || curhref.indexOf("sogou.com") > -1){ (function(c_curhref){ GM_xmlhttpRequest({ url: c_curhref, headers: { "Accept": "text/html" }, method: "GET", onreadystatechange:function(response) { if(response.status==200){ DealResult(response, c_curhref); } } }); })(curhref); //传递旧的网址过去,读作c_curhref }else if(curhref.indexOf("/interstitial") > -1){ }else{ //console.log("绕过百度重定向直接访问网页: 第"+i+"个已经处理了"); } } } } function DealResult(response, c_curhref){ var resultURL = response.finalUrl; if(Stype.length > 10){ //如果是搜狗的结果 var resultResponseUrl = Reg_Get(response.responseText, "URL='([^']+)'"); if(resultResponseUrl !== null) resultURL = resultResponseUrl; } var indexhref = Reg_Get(c_curhref, "((?:http)[^&]+)");// 必须要提取部分数据,因为之后的莫名加了其他参数ck=0.0.0.0..... var ccnode = document.querySelectorAll("h3>[href*='"+indexhref+"']")[0]; if(ccnode != null){ ccnode.href = resultURL; }else{ console.log("该链接已经被其他脚本干掉了哦"+resultURL); } } function Reg_Get(HTML, reg){ var RegE = new RegExp(reg); return RegE.exec(HTML)[1]; } })();