remove the jump link in BAIDU (ECMA6)

去除百度搜索跳转链接

目前為 2016-04-17 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 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 (ECMA6)
// @author            axetroy
// @collaborator      axetroy
// @description       去除百度搜索跳转链接
// @version           2016.4.17
// @grant             GM_xmlhttpRequest
// @include           *www.baidu.com*
// @connect           *www.baidu.com*
// @compatible        chrome  完美运行
// @compatible        firefox  完美运行
// @supportURL        http://www.burningall.com
// @run-at            document-start
// @contributionURL   [email protected]|alipay.com
// @namespace         https://greasyfork.org/zh-CN/users/3400-axetroy
// @license           The MIT License (MIT); http://opensource.org/licenses/MIT
// ==/UserScript==

// Github源码:https://github.com/axetroy/GMscript/tree/master/remove_baidu_redirect

/* jshint ignore:start */

!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d=function(a){var b=document,c=b.createElement("style");if(c.setAttribute("type","text/css"),c.setAttribute("id","remove_redirect_debug"),c.styleSheet)c.styleSheet.cssText=a;else{var d=b.createTextNode(a);c.appendChild(d)}var e=b.getElementsByTagName("head");e.length?e[0].appendChild(c):b.documentElement.appendChild(c)},e=function(a){var b=document.getElementById("remove_redirect_debug");!b&&d(a)};b.exports=e},{}],2:[function(a,b,c){"use strict";var d=function(a,b,c,d){var e,f,g,h=+new Date,i=0,j=0,k=null,l=function(){j=h,a.apply(f,g)};return function(){h=+new Date,f=this,g=arguments,e=h-(d?i:j)-b,clearTimeout(k),d?c?k=setTimeout(l,b):e>=0&&l():e>=0?l():c&&(k=setTimeout(l,-e)),i=h}},e=function(a,b,c){return d(a,b,c,!0)};b.exports={$debounce:e,$throttle:d}},{}],3:[function(a,b,c){"use strict";var d=a("./$q"),e=a("./jqLite"),f=function(){var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],b=d.defer(),c=function(c){4===c.readyState&&(c.requestUrl=a.url,/^(2|3)/.test(c.status)||c.finalUrl?b.resolve(c):b.reject(c))},f=function(c){c.requestUrl=a.url,c&&c.finalUrl?b.resolve(c):b.reject(c)},g=function(c){c.requestUrl=a.url,c&&c.finalUrl?b.resolve(c):b.reject(c)};return a=e.fn.merge({onreadystatechange:c,ontimeout:f,onerror:g},a),new RegExp("^"+window.location.protocol).test(a.url)||(a.url=a.url.replace(/^(http|https):/im,window.location.protocol)),GM_xmlhttpRequest(a),b.promise};["HEAD","GET","POST"].forEach(function(a){f[a.toLocaleLowerCase()]=function(b){var c=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],g=d.defer();return c=e.fn.merge(c,{url:b,method:a}),f(c).then(function(a){g.resolve(a)},function(a){g.reject(a)}),g.promise}}),f.jsonp=function(a){var b=d.defer(),c=document.createElement("script");return c.setAttribute("type","text/javascript"),c.src=a+"?callback=func",document.body.appendChild(c),b.promise},b.exports=f},{"./$q":4,"./jqLite":5}],4:[function(a,b,c){"use strict";var d=a("es6-promise"),e=(d.polyfill,d.Promise),f=function(){var a=arguments.length<=0||void 0===arguments[0]?noop:arguments[0];return new e(a)};f.defer=function(){var a={};return a.promise=new e(function(b,c){a.resolve=function(a){b(a)},a.reject=function(a){c(a)}}),a},f.resolve=function(a){return f(function(b,c){b(a)})},f.reject=function(a){return f(function(b,c){c(a)})},b.exports=f},{"es6-promise":6}],5:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=function(a){return a},g=function(){function a(){var b=this,c=arguments.length<=0||void 0===arguments[0]?"":arguments[0],e=arguments.length<=1||void 0===arguments[1]?document:arguments[1];switch(d(this,a),this.selectors=c,this.context=e,this.length=0,typeof c){case"undefined":break;case"string":Array.from(e.querySelectorAll(c),function(a,c){b[c]=a,b.length++},this);break;case"object":c.length?Array.from(c,function(a,c){b[c]=a,b.length++},this):(this[0]=c,this.length=1);break;case"function":this.ready(c)}}return a.prototype.each=function(){for(var a=arguments.length<=0||void 0===arguments[0]?f:arguments[0],b=0;b<this.length;b++)a.call(this,this[b],b);return this},a.prototype.bind=function(){var a=arguments.length<=0||void 0===arguments[0]?"":arguments[0],b=arguments.length<=1||void 0===arguments[1]?f:arguments[1];this.each(function(c){a.trim().split(/\s{1,}/).forEach(function(a){c.addEventListener(a,function(a){var c=a.target||a.srcElement;return b.call(c,a)===!1?(a.returnValue=!0,a.cancelBubble=!0,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),!1):void 0},!1)})})},a.prototype.ready=function(){var a=this,b=arguments.length<=0||void 0===arguments[0]?f:arguments[0];this.context.addEventListener("DOMContentLoaded",function(c){b.call(a)},!1)},a.prototype.observe=function(){var a=this,b=arguments.length<=0||void 0===arguments[0]?f:arguments[0],c=arguments.length<=1||void 0===arguments[1]?{childList:!0,subtree:!0}:arguments[1];return this.each(function(d){var e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,f=new e(function(c){c.forEach(function(c){b.call(a,c.target,c.addedNodes,c.removedNodes)})});f.observe(d,c)}),this},a.prototype.attr=function(a,b){return 1!==arguments.length?2===arguments.length?(this.each(function(c){c.setAttribute(a,b)}),this):this:"string"==typeof a?this[0].getAttribute(a):"object"==typeof a?(this.each(function(c){for(var d in a)a.hasOwnProperty(d)&&c.setAttribute(d,b)}),b):void 0},a.prototype.removeAttr=function(a){return 1===arguments.length&&this.each(function(b){b.removeAttribute(a)}),this},e(a,[{key:"text",get:function(){var a=this[0];return a.innerText?a.innerText:a.textContent}}],[{key:"fn",get:function(){var a=function(a){var b=a.getBoundingClientRect(),c=void 0,d=void 0,e=void 0,f=document.documentElement,g=document.body;return f.getBoundingClientRect?(c=f.clientWidth||g.clientWidth,d=f.clientHeight||g.clientHeight,e=b.top>d||b.bottom<0||b.left>c||b.right<0,!e):void 0},b=function(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return Object.assign.apply(Object,[{}].concat(b))};return{visible:a,merge:b}}}]),a}(),h=function(){var a=arguments.length<=0||void 0===arguments[0]?"":arguments[0],b=arguments.length<=1||void 0===arguments[1]?document:arguments[1];return new g(a,b)};h.fn=g.fn,b.exports=h},{}],6:[function(a,b,c){(function(c,d){(function(){"use strict";function e(a){return"function"==typeof a||"object"==typeof a&&null!==a}function f(a){return"function"==typeof a}function g(a){T=a}function h(a){X=a}function i(){return function(){c.nextTick(n)}}function j(){return function(){S(n)}}function k(){var a=0,b=new $(n),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function l(){var a=new MessageChannel;return a.port1.onmessage=n,function(){a.port2.postMessage(0)}}function m(){return function(){setTimeout(n,1)}}function n(){for(var a=0;W>a;a+=2){var b=ba[a],c=ba[a+1];b(c),ba[a]=void 0,ba[a+1]=void 0}W=0}function o(){try{var b=a,c=b("vertx");return S=c.runOnLoop||c.runOnContext,j()}catch(d){return m()}}function p(a,b){var c=this,d=c._state;if(d===fa&&!a||d===ga&&!b)return this;var e=new this.constructor(r),f=c._result;if(d){var g=arguments[d-1];X(function(){H(d,e,g,f)})}else D(c,e,a,b);return e}function q(a){var b=this;if(a&&"object"==typeof a&&a.constructor===b)return a;var c=new b(r);return z(c,a),c}function r(){}function s(){return new TypeError("You cannot resolve a promise with itself")}function t(){return new TypeError("A promises callback cannot return that same promise.")}function u(a){try{return a.then}catch(b){return ha.error=b,ha}}function v(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function w(a,b,c){X(function(a){var d=!1,e=v(c,b,function(c){d||(d=!0,b!==c?z(a,c):B(a,c))},function(b){d||(d=!0,C(a,b))},"Settle: "+(a._label||" unknown promise"));!d&&e&&(d=!0,C(a,e))},a)}function x(a,b){b._state===fa?B(a,b._result):b._state===ga?C(a,b._result):D(b,void 0,function(b){z(a,b)},function(b){C(a,b)})}function y(a,b,c){b.constructor===a.constructor&&c===ca&&constructor.resolve===da?x(a,b):c===ha?C(a,ha.error):void 0===c?B(a,b):f(c)?w(a,b,c):B(a,b)}function z(a,b){a===b?C(a,s()):e(b)?y(a,b,u(b)):B(a,b)}function A(a){a._onerror&&a._onerror(a._result),E(a)}function B(a,b){a._state===ea&&(a._result=b,a._state=fa,0!==a._subscribers.length&&X(E,a))}function C(a,b){a._state===ea&&(a._state=ga,a._result=b,X(A,a))}function D(a,b,c,d){var e=a._subscribers,f=e.length;a._onerror=null,e[f]=b,e[f+fa]=c,e[f+ga]=d,0===f&&a._state&&X(E,a)}function E(a){var b=a._subscribers,c=a._state;if(0!==b.length){for(var d,e,f=a._result,g=0;g<b.length;g+=3)d=b[g],e=b[g+c],d?H(c,d,e,f):e(f);a._subscribers.length=0}}function F(){this.error=null}function G(a,b){try{return a(b)}catch(c){return ia.error=c,ia}}function H(a,b,c,d){var e,g,h,i,j=f(c);if(j){if(e=G(c,d),e===ia?(i=!0,g=e.error,e=null):h=!0,b===e)return void C(b,t())}else e=d,h=!0;b._state!==ea||(j&&h?z(b,e):i?C(b,g):a===fa?B(b,e):a===ga&&C(b,e))}function I(a,b){try{b(function(b){z(a,b)},function(b){C(a,b)})}catch(c){C(a,c)}}function J(a){return new oa(this,a).promise}function K(a){function b(a){z(e,a)}function c(a){C(e,a)}var d=this,e=new d(r);if(!V(a))return C(e,new TypeError("You must pass an array to race.")),e;for(var f=a.length,g=0;e._state===ea&&f>g;g++)D(d.resolve(a[g]),void 0,b,c);return e}function L(a){var b=this,c=new b(r);return C(c,a),c}function M(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function N(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function O(a){this._id=ma++,this._state=void 0,this._result=void 0,this._subscribers=[],r!==a&&("function"!=typeof a&&M(),this instanceof O?I(this,a):N())}function P(a,b){this._instanceConstructor=a,this.promise=new a(r),Array.isArray(b)?(this._input=b,this.length=b.length,this._remaining=b.length,this._result=new Array(this.length),0===this.length?B(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&B(this.promise,this._result))):C(this.promise,this._validationError())}function Q(){var a;if("undefined"!=typeof d)a=d;else if("undefined"!=typeof self)a=self;else try{a=Function("return this")()}catch(b){throw new Error("polyfill failed because global object is unavailable in this environment")}var c=a.Promise;c&&"[object Promise]"===Object.prototype.toString.call(c.resolve())&&!c.cast||(a.Promise=na)}var R;R=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)};var S,T,U,V=R,W=0,X=function(a,b){ba[W]=a,ba[W+1]=b,W+=2,2===W&&(T?T(n):U())},Y="undefined"!=typeof window?window:void 0,Z=Y||{},$=Z.MutationObserver||Z.WebKitMutationObserver,_="undefined"!=typeof c&&"[object process]"==={}.toString.call(c),aa="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,ba=new Array(1e3);U=_?i():$?k():aa?l():void 0===Y&&"function"==typeof a?o():m();var ca=p,da=q,ea=void 0,fa=1,ga=2,ha=new F,ia=new F,ja=J,ka=K,la=L,ma=0,na=O;O.all=ja,O.race=ka,O.resolve=da,O.reject=la,O._setScheduler=g,O._setAsap=h,O._asap=X,O.prototype={constructor:O,then:ca,"catch":function(a){return this.then(null,a)}};var oa=P;P.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},P.prototype._enumerate=function(){for(var a=this.length,b=this._input,c=0;this._state===ea&&a>c;c++)this._eachEntry(b[c],c)},P.prototype._eachEntry=function(a,b){var c=this._instanceConstructor,d=c.resolve;if(d===da){var e=u(a);if(e===ca&&a._state!==ea)this._settledAt(a._state,b,a._result);else if("function"!=typeof e)this._remaining--,this._result[b]=a;else if(c===na){var f=new c(r);y(f,a,e),this._willSettleAt(f,b)}else this._willSettleAt(new c(function(b){b(a)}),b)}else this._willSettleAt(d(a),b)},P.prototype._settledAt=function(a,b,c){var d=this.promise;d._state===ea&&(this._remaining--,a===ga?C(d,c):this._result[b]=c),0===this._remaining&&B(d,this._result)},P.prototype._willSettleAt=function(a,b){var c=this;D(a,void 0,function(a){c._settledAt(fa,b,a)},function(a){c._settledAt(ga,b,a)})};var pa=Q,qa={Promise:na,polyfill:pa};"function"==typeof define&&define.amd?define(function(){return qa}):"undefined"!=typeof b&&b.exports?b.exports=qa:"undefined"!=typeof this&&(this.ES6Promise=qa),pa()}).call(this)}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:8}],7:[function(a,b,c){"use strict";!function(){var b=a("./../libs/jqLite"),c=a("./src/init"),d=a("./src/observe"),e=a("./src/mouseover"),f=a("./src/scroll");b(function(){c(),d(),e(),f()}),console.info("去跳转启动...")}()},{"./../libs/jqLite":5,"./src/init":10,"./src/mouseover":12,"./src/observe":13,"./src/scroll":14}],8:[function(a,b,c){function d(){k=!1,h.length?j=h.concat(j):l=-1,j.length&&e()}function e(){if(!k){var a=setTimeout(d);k=!0;for(var b=j.length;b;){for(h=j,j=[];++l<b;)h&&h[l].run();l=-1,b=j.length}h=null,k=!1,clearTimeout(a)}}function f(a,b){this.fun=a,this.array=b}function g(){}var h,i=b.exports={},j=[],k=!1,l=-1;i.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];j.push(new f(a,b)),1!==j.length||k||setTimeout(e,0)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.binding=function(a){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(a){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],9:[function(a,b,c){"use strict";var d={rules:'\n      a[href*="www.baidu.com/link?url"]\n      :not(.m)\n      :not([decoding])\n      :not([decoded])\n    '.trim().replace(/\n/gim,"").replace(/\s{1,}([^a-zA-Z])/g,"$1"),debug:!1,debugStyle:"\n  a[decoded]{\n    background-color:green !important;\n    color:#303030 !important;\n  };\n  a[decoding]{\n    background-color:yellow !important;\n    color:#303030 !important;\n  }\n  ",isDecodingAll:!1};b.exports=d},{}],10:[function(a,b,c){"use strict";var d=a("../../libs/$q"),e=a("./main"),f=a("./config"),g=function(){new e(f.rules).all().then(function(){return d.resolve(!0)},function(){return d.resolve(!0)}).then(function(){new e(f.rules).oneByOne()})};b.exports=g},{"../../libs/$q":4,"./config":9,"./main":11}],11:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var e=a("../../libs/jqLite"),f=a("../../libs/$q"),g=a("../../libs/$http"),h=a("./config"),i=function(){function a(){var b=this,c=arguments.length<=0||void 0===arguments[0]?"":arguments[0];return d(this,a),c?(this.inViewPort=[],void e(c).each(function(a){return e.fn.visible(a)&&b.inViewPort.push(a)})):this}return a.prototype.all=function(){var a=f.defer(),b=window.top.location.href.replace(/(\&)(tn=\w+)(\&)/gim,"$1tn=baidulocal$3");return h.isDecodingAll=!0,g.get(b,{timeout:2e3}).then(function(b){if(h.isDecodingAll=!1,b){var c=b.responseText;c=c.replace(/(src=[^>]*|link=[^>])/g,"");var d=document.createElement("html");d.innerHTML=c,e(".t>a:not(.OP_LOG_LINK):not([decoded])").each(function(a){e(".f>a",d).each(function(b){e(a).text===e(b).text&&(a.href=b.href,e(a).attr("decoded",!0))})}),a.resolve(b)}},function(b){h.isDecodingAll=!1,a.reject(b)}),a.promise},a.prototype.one=function(a){var b=f.defer();return e(a).attr("decoding",!0),g.head(a.href,{timeout:2e3,anonymous:!0}).then(function(c){e(a).attr("href",c.finalUrl).attr("decoded",!0).removeAttr("decoding"),b.resolve(c)},function(c){e(a).removeAttr("decoding"),b.reject(c)}),b.promise},a.prototype.oneByOne=function(){var b=this;return e(this.inViewPort).each(function(c){a.match(c)&&b.one(c)}),this},a.match=function(a){return"A"===a.tagName&&a.href&&/www\.baidu\.com\/link\?url=/im.test(a.href)&&!e(a).attr("decoded")&&!e(a).attr("decoding")},a}();b.exports=i},{"../../libs/$http":3,"../../libs/$q":4,"../../libs/jqLite":5,"./config":9}],12:[function(a,b,c){"use strict";var d=a("../../libs/jqLite"),e=a("../../libs/$debounce").$debounce,f=a("./main"),g=e(function(a){var b=a.target;"A"===b.tagName&&b.href&&/www\.baidu\.com\/link\?url=/im.test(b.href)&&!d(b).attr("decoded")&&(new f).one(b)},100,!0),h=function(){d(document).bind("mouseover",function(a){g(a)})};b.exports=h},{"../../libs/$debounce":2,"../../libs/jqLite":5,"./main":11}],13:[function(a,b,c){"use strict";var d=a("../../libs/jqLite"),e=a("../../libs/$debounce").$debounce,f=a("../../libs/$addStyle"),g=a("./main"),h=a("./init"),i=a("./config"),j=function(){var a=e(function(a){var b=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];b.length&&(i.isDecodingAll?new g(i.rules).oneByOne():h(),i.debug&&f(i.debugStyle))},100);d(document).observe(function(b){var c=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],d=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];a(b,c,d)})};b.exports=j},{"../../libs/$addStyle":1,"../../libs/$debounce":2,"../../libs/jqLite":5,"./config":9,"./init":10,"./main":11}],14:[function(a,b,c){"use strict";var d=a("../../libs/jqLite"),e=a("../../libs/$debounce").$debounce,f=a("../../libs/$addStyle"),g=a("./main"),h=a("./config"),i=function(){var a=e(function(){new g(h.rules).oneByOne(),h.debug&&f(h.debugStyle)},100);d(window).bind("scroll",function(){a()})};b.exports=i},{"../../libs/$addStyle":1,"../../libs/$debounce":2,"../../libs/jqLite":5,"./config":9,"./main":11}]},{},[7]);
//# sourceMappingURL=index.map

/* jshint ignore:end */