代码拉取完成,页面将自动刷新
// ==UserScript==
// @name Baidu Mask
// @namespace http://tampermonkey.net/
// @version 0.1
// @description hide areas which made distraction in some baidu and other sites
// @description require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.jss
// @author liyzh
// @match *://www.baidu.com/*
// @match *://baike.baidu.com/*
// @match *://zhidao.baidu.com/*
// @match *://www.weather.com.cn/*
// @match *://blog.sina.com.cn/*
// @match *://blog.163.com/*
// @match *://blog.csdn.net/*
// @match *://www.google.com/*
// @match *://www.zhihu.com/*
// @match *://www.appinn.com/*
// @match *://www.jianshu.com/*
// @match *://www.sohu.com/*
// @grant none
// @run-at document-start
// @noframes
// ==/UserScript==
(function () {
'use strict';
// Your code here...
var $j;
function GM_wait() {
if (typeof jQuery === 'undefined') {
window.setTimeout(GM_wait, 100);
}
else {
$j = jQuery.noConflict();
doJob();
}
}
function loadJquery() {
// Check if jQuery's loaded
if (typeof jQuery === 'undefined') {
// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'https://code.jquery.com/jquery-1.12.4.min.js';
GM_JQ.type = 'text/javascript';
GM_JQ.id = 'jquery-lyz';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
GM_wait();
} else {
doJob();
}
}
loadJquery();
function doJob() {
if (typeof $j === 'undefined') {
$j = $;
}
var url_arr = [
{'name': "baidu", 'value': "www.baidu.com"},
{'name': "baike", 'value': "baike.baidu.com"},
{'name': "zhidao", 'value': "zhidao.baidu.com"},
{'name': "weather", 'value': "www.weather.com.cn"},
{'name': "blog_sina", 'value': "blog.sina.com.cn"},
{'name': "blog_163", 'value': "blog.163.com"},
{'name': "blog_csdn", 'value': "blog.csdn.net"},
{'name': "google", 'value': "www.google.com"},
{'name': "zhihu", 'value': "www.zhihu.com"},
{'name': "appinn", 'value': "www.appinn.com"},
{'name': "jianshu", 'value': "www.jianshu.com"},
{'name': "sohu", 'value': "www.sohu.com"},
];
var url = location.href;
var siteObj = {};
$j(url_arr).each(function (i, item) {
if (url.indexOf(item.value) > -1) {
siteObj = item;
return false;
}
});
var selector = '';
var remove_selector = '';
var empty_selector = '';
var timerLimit = 20;
switch (siteObj.name) {
case 'baidu':
selector = '#content_right';
$j('#kw').change(function (evt) {
doJob();
});
break;
case 'baike':
selector = '.topA, .lemmaWgt-promotion-slide, .union-content, .right-ad, ' +
'.lemmaWgt-promotion-vbaike, .nav-menu, #side_box_unionAd, .after-content';
break;
case 'zhidao':
selector = '.widget-new-graphic, #union-asplu, .jump-top-box, .wgt-daily,' +
'.shop-entrance, .cms-slide, .nav-menu, iframe';
remove_selector = '.wgt-daily';
break;
case 'weather':
selector = '.right, .hdImgs, .tq_zx, #di_tan, #zu_dui, iframe';
remove_selector = 'iframe';
break;
case 'blog_sina':
selector = '.BNE_blog_feed, .blogreco, .sinaad-toolkit-box, #module_903, #module_904, ' +
'#ramdomVisitDiv, .ntopbar_ad, .sinaads, #sinaadToolkitBox3';
remove_selector = '.sinaad-toolkit-box, .sinaads, .ntopbar_ad';
timerLimit = 30;
break;
case 'blog_163':
selector = '.m-fixedPCAd, .nb-layer, .m-lofteriframe, .m-163news';
remove_selector = '.m-fixedPCAd';
empty_selector = '.m-lofteriframe iframe';
break;
case 'blog_csdn':
selector = '.fixRight iframe, .flashrecommend';
break;
case 'google':
selector = '.gb_Kc';
break;
case 'zhihu':
selector = '.Sticky';
remove_selector = '.AppHeader-notifications, .AppHeader-messages';
break;
case 'appinn':
selector = '.sidebar, iframe';
break;
case 'jianshu':
selector = '.note-bottom, #web-note-ad-1';
remove_selector = '#web-note-ad-fixed';
break;
case 'sohu':
selector = '#right-side-bar, .groom-read';
break;
}
var delay_arr = selector.split(',');
var timerCount = 1;
function hideTimer() {
timerCount++;
if (timerCount > timerLimit) {
return;
}
delay_arr = $j.grep(delay_arr, function (_selector, i) {
var $ele = $j(_selector);
var visible = $ele.is(':visible');
console.log($ele, visible);
if (visible) {
//$ele.hide();
$ele.css('display', 'none');
// $ele.remove();
return false;
}
return true; // keep the element in the array
});
if (delay_arr.length > 0) {
setTimeout(hideTimer, 500);
}
//console.log($j(watch_selector));
console.log($j(empty_selector));
$j(remove_selector).remove();
$j(empty_selector).empty();
$j(empty_selector).attr('src', '');
}
setTimeout(hideTimer, 1);
}
})();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。