remove the jump link in BAIDU

去除百度搜索跳转链接

目前為 2015-09-22 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name    remove the jump link in BAIDU
// @author  burningall
// @description 去除百度搜索跳转链接
// @version     2015.9.22.1.0
// @include     *www.baidu.com*
// @grant       GM_setValue
// @grant       GM_getValue
// @grant       GM_registerMenuCommand
// @grant       GM_xmlhttpRequest
// @run-at      document-start
// @compatible  chrome  完美运行
// @compatible  firefox  完美运行
// @license     The MIT License (MIT); http://opensource.org/licenses/MIT
// @supportURL      http://www.burningall.com
// @contributionURL [email protected]|alipay.com
// @namespace https://greasyfork.org/zh-CN/users/3400-axetroy
// ==/UserScript==
(function(d,f,b){var a={macthRules:'a[href*="www.baidu.com/link?url"]:not([transcoding]):not([transcoded]):not([transcodedAll]):not(.m)',transcodingAll:false,mixRequireMod:true};function j(k){return new g(k)}function g(k){this.element=k;return this}g.prototype.addEvent=function(l,k){var n=this.element,m;return n.addEventListener?n.addEventListener(l,function(o){m=d.event?d.event:(o?o:null);m.target=m.target||m.srcElement;k.call(n,m)},false):n.attachEvent("on"+l,function(o){m=d.event?d.event:(o?o:null);m.target=m.target||m.srcElement;k.call(n,m)})};g.prototype.bind=function(o,n){var p=this.element;if(arguments.length==1){for(var k in o){this.addEvent(k,o[k])}}else{if(arguments.length==2){var m=o.split(" "),l=0;while(l<m.length){this.addEvent(m[l],n);l++}}}return this};g.prototype.ob=function(l,m){var o=this.element,n=d.MutationObserver||d.WebKitMutationObserver||d.MozMutationObserver,k=new n(function(p){p.forEach(function(q){m.call(o)})});k.observe(o,l);return this};function h(k){return k.innerText?k.innerText:k.textContent}function e(l,m,k){k=k?k:d;if(m.beforeFn){if(m.beforeFn.call(k,l)===false){return}}GM_xmlhttpRequest({method:"GET",url:l,onreadystatechange:function(o){if(o.readyState==4){var n=o.status+"",p=n.charAt(0);if(p<4){if(m.successFn){m.successFn.call(k,o.responseText,l)}}}}})}function i(k){return new c(k)}function c(n){if(!n){return this}this.jumpLinks=f.querySelectorAll(n);this.visible();var l=f.querySelectorAll("#content_left *[data-click]");for(var m=0,k=l.length;m<k;m++){l[m].removeAttribute("data-click")}return this}c.prototype.all=function(m){var l=f.getElementById("kw").value,k=d.top.location.href.replace("https","http").replace(/(\&)(tn=\w+)(\&)/img,"$1"+"tn=baidulocal"+"$3").replace(/(\&)(wd=\w+)(\&)/img,"$1"+"wd="+l+"$3");e(k,{"beforeFn":function(n){a.transcodingAll=true},"successFn":function(r,n){var u=f.createElement("html");u.innerHTML=r.replace(/http\:\/\/(.*)\.gif/img,"http://wwwbaidu.com");var x=u.querySelectorAll(".f>a"),q={};for(var t=0,p=x.length;t<p;t++){if(q[x[t].href]===b){q[x[t].href]=h(x[t])}}var w=f.querySelectorAll(".t>a:not(.OP_LOG_LINK):not([transcoded]):not([transcodedAll])");for(var o in q){for(var s=0,v=w.length;s<v;s++){if(q[o].replace(/\s*/img,"")==h(w[s]).replace(/\s*/img,"")){w[s].href=o;w[s].setAttribute("transcodedAll","true");w[s].setAttribute("transcoded","true")}}}a.transcodingAll=false;if(m){m()}}})};c.prototype.onebyone=function(){var l=this.inViewPort.length;if(l<=0){return}for(var k=0;k<l;k++){this.a=this.inViewPort[k];if(this.a.getAttribute("transcodedAll")){continue}e(this.a.href.replace("http","https")+"&wd=&eqid=0",{"beforeFn":function(m){this.setAttribute("transcoding","true")},"successFn":function(o,n){var m=o.match(/\(\"\S+\"\)/img)[0].replace(/^[\(\"]*|[\)\"]*$/img,"");this.href=m;this.removeAttribute("transcoding");this.setAttribute("transcoded","true")}},this.a)}return this};c.prototype.visible=function(){var l,r,s,p,n,o,k=[];for(var m=0,q=this.jumpLinks.length;m<q;m++){l=this.jumpLinks[m];r=l.getBoundingClientRect();s=f.documentElement.clientWidth||f.body.clientWidth;p=f.documentElement.clientHeight||f.body.clientHeight;n=r.top>p||r.bottom<0||r.left>s||r.right<0;o=!n&&k.push(l)}this.inViewPort=k;return this};j(f).bind({"DOMContentLoaded":function(){if(a.transcodingAll===false){i().all(function(){i(a.macthRules).onebyone();var k=f.getElementById("wrapper");j(k).ob({"childList":true,"subtree":true},function(){if(a.transcodingAll||f.querySelectorAll("a[transcodedAll]").length>0){i(a.macthRules).onebyone()}else{i().all(function(){i(a.macthRules).onebyone()})}})})}},"mouseover":function(m){var k=m.target;if(k.tagName=="A"&&/www.baidu.com\/link\?url=/img.test(k.href)&&k.getAttribute("transcoded")!=="true"){var l=k.href.replace("http","https")+"&wd=&eqid=0";e(l,{"beforeFn":function(n){this.setAttribute("transcoding","true")},"successFn":function(p,o){var n=p.match(/\(\"\S+\"\)/img)[0].replace(/^[\(\"]*|[\)\"]*$/img,"");this.href=n;this.removeAttribute("transcoding");this.setAttribute("transcoded","true")}},k)}}});j(d).bind("scroll",function(){i(a.macthRules).onebyone()})})(window,document,undefined);