Greasy Fork is available in English.
try to take over the world!
当前为
// ==UserScript==
// @name 百度搜索去除n+
// @namespace http://tampermonkey.net/
// @version 0.1.7
// @description try to take over the world!
// @author MT-戒酒的李白染
// @match https://www.baidu.com/from=*
// @match https://www.baidu.com/s?word=*
// @grant GM_addStyle
// @require http://cdn.staticfile.org/jquery/2.1.4/jquery.min.js
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
function main_start() {
$(".search-page").bind("DOMSubtreeModified",
function(e) {
console.log("节点改变");
if ($(".c-container.na-ec-item").length != 0) {
$(".c-container.na-ec-item")[0].remove()
};
if ($(".c-recomm-wrap.new-ux-recom-wrapper.animation").length != 0) {
$(".c-recomm-wrap.new-ux-recom-wrapper.animation")[0].remove()
};
var tpl_len2 = $(".c-result.result").length;
for (var j = 0; j < tpl_len; j++) {
if(($(".c-result.result")[j].children.length==1)||(tpl_len2 == "recommend_list")){
$(".c-result.result")[j].remove();
j--;
tpl_len2--;
}
}
});
var tpl_len = $(".c-result.result").length;
var i=0;
try {
for (i = 0; i < tpl_len; i++) {
var real_url = JSON.parse($(".c-result.result")[i].attributes["data-log"].value)["mu"];
var tpl_text = $(".c-result.result")[i].attributes.tpl.textContent;
$(".c-gap-inner-bottom-lh")[i].children[0].href = real_url //中间
$(".c-result.result")[i].children[0].children[0].attributes["rl-link-href"].value = real_url //标题
// if(($(".c-result.result")[i].children.length==1)||(tpl_text == "recommend_list")){
// $(".c-result.result")[i].remove();
// }
}
} catch(err) {
if(err.name=="TypeError"){
$(".c-result.result")[i].remove();
console.log("捕获错误后删除");
}else{
console.log(err);
}
console.log(err);
}
}
GM_addStyle(".c-container.na-ec-item,.c-recomm-wrap.new-ux-recom-wrapper.animation{display:none}")
$(function(){main_start();})
})();