在chrome中屏蔽百度推荐
方法1:可以使用adblock plus来进行屏蔽;
需要将chrome的扩展程序打开为调试者模式;
下载地址:http://chromecj.com/productivity/2014-07/24/download.html
https://files.cnblogs.com/files/stono/AdblockPlus.rar
https://files.cnblogs.com/files/stono/AdblockPlus.tar
屏蔽规则:
baidu.com###content_right
baidu.com##.cr-offset
www.baidu.com###content_right
www.baidu.com##.cr-offset
方法2:使用adblock进行屏蔽,最近想adblock plus不太好用
下载地址:http://www.xdowns.com/soft/1/16/2017/Soft_224728.html
需要自己编辑屏蔽规则,规则如上;
https://files.cnblogs.com/files/stono/adblock.tar
方法3:可以自己写脚本;效果不好
学习:https://blog.csdn.net/pyufftj/article/details/73479898
chrome的插件tampermonkey(油猴,在firefox下面叫做greasymonkey)
注意@math的写法: // @match *://*.baidu.com/*
tampermonkey使用:http://www.pc6.com/infoview/Article_115189.html
tampermonkey插件下载:https://greasyfork.org/zh-CN/scripts
方法4:自己编写chrome扩展,屏蔽百度推荐
学习了:https://www.cnblogs.com/liuxianan/p/chrome-plugin-develop.html
https://files.cnblogs.com/files/stono/mycrx.tar
// ### manifest.json
{
"manifest_version": 2,
"name": "mycrx",
"version": "1.0.0",
"background":
{
"scripts": ["js/background.js"]
},
"content_scripts":
[
{
"matches": ["<all_urls>"],
"js":["js/jquery-2.1.1.min.js","js/content-script.js"],
"run_at":"document_end"
}
],
"permissions":
[
"contextMenus"
],
"web_accessible_resources": ["js/inject.js"]
}
// ### inject.js
try{
$(function () {
console.log('this is from chrome extension inject js');
window.setInterval(function() {
$('#content_right').css("display","none");
}, 1000);
});
}catch(e){}
// ### content-script.js
$(function () {
$('#content_right').css("display","none");
console.log("this is from content script");
injectCustomJs();
});
// 向页面注入JS
function injectCustomJs(jsPath)
{
jsPath = jsPath || 'js/inject.js';
var temp = document.createElement('script');
temp.setAttribute('type', 'text/javascript');
// 获得的地址类似:chrome-extension://ihcokhadfjfchaeagdoclpnjdiokfakg/js/inject.js
temp.src = chrome.extension.getURL(jsPath);
temp.onload = function()
{
// 放在页面不好看,执行完后移除掉
this.parentNode.removeChild(this);
};
document.head.appendChild(temp);
}
// ### background.js
chrome.contextMenus.create({
title: "baidu: %s",
contexts: ['selection'],
onclick: function (params) {
chrome.tabs.create({url:'https://www.baidu.com/s?ie=utf-8&wd='+encodeURI(params.selectionText)});
}
});
扩展安装时候,源文件不要轻易删除,删除之后点击插件管理界面chrome://extensions/上的“插件刷新小按钮”会导致插件失效失效,然后就不能用了;
需要删除原来的插件,然后重新安装;