Commit b357037b authored by 邱旭's avatar 邱旭

init

parents
File added
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="HtmlRequiredAltAttribute" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/百度广告屏蔽.iml" filepath="$PROJECT_DIR$/.idea/百度广告屏蔽.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
{
"manifest_version": 2, // 清单版本号
"name": "插件名称",
"version": "1.8.6", // 版本号
"description": "描述",
"author": "作者",
"icons": { // 图标
"16": "xxx.png",
"48": "xxx.png",
"128": "xxx.png"
},
// browser_action page_action 只能添加一个
"browser_action": { // 浏览器行为,所有页面均生效
"default_icon": "xxx.png",// 图标的图片
"default_title": "标题",
"default_popup": "html/popup.html" //单击图标后弹窗页面
},
"page_action":{ // 页面行为,只在特定页面下生效
"default_icon":{
"24":"xxx.png",
"38":"xxx.png"
},
"default_popup": "xxx.html",
"default_title":"页面标题"
},
"background": { // 后台脚本,可简单理解为服务器
"scripts": [
"xxx.js",
]
},
"devtools_page": "xxx.html",
"content_scripts": [ // 注入的脚本,css等
{
"js":["xxx.js"],
"css": ["xxx.css"],
"matches":["<all_urls>"] // 只在这些站点下生效 <all_urls> 表示全部
}
],
"permissions": [ // 所需要的权限
"cookies",
"http://*/*",
"management",
"tabs",
"contextMenus"
]
}
/*
* index.js.js
* Created by 还有醋v on 2021/6/17.
* Copyright © 2021 haiyoucuv. All rights reserved.
*/
// PC端搜索广告
const content_left = document.getElementById("content_left");
console.log("PC端搜索广告:", content_left);
if (content_left && content_left.children > 0 && !content_left.children[0].id) {
content_left.children[0].remove();
}
// 手机端搜索广告
const ec_wise_ad = document.getElementsByClassName("ec_wise_ad");
console.log("手机端搜索广告:", ec_wise_ad);
if (ec_wise_ad[0]) {
ec_wise_ad[0].remove();
}
/**
* 通过监听dom树的变化,移除异步加载的的广告
*/
function removeAdAsync() {
// 百科右侧图片广告
const right_ad = document.getElementsByClassName("right-ad");
if (right_ad[0]) {
console.log("百科右侧图片广告", right_ad);
right_ad[0].remove();
}
// 百科右侧恶心的广告
const side_box_unionAd = document.getElementById("side_box_unionAd");
if (side_box_unionAd) {
console.log("百科右侧恶心的广告", right_ad);
side_box_unionAd.remove();
}
}
// 监听dom结构变化 DOM2
// document.body.addEventListener("DOMSubtreeModified", ()=>{
// console.log("DOMSubtreeModified");
// });
// 监听dom结构变化 DOM3
const observer = new MutationObserver(removeAdAsync);
observer.observe(document.body, {
childList: true,
// attributes: true,
subtree: true,
});
{
"manifest_version": 2,
"name": "百度广告屏蔽器",
"version": "0.0.1",
"description": "屏蔽天杀的百度广告",
"icons": {
},
"author": "haiyoucuv",
"content_scripts": [
{
"js":["index.js"],
"css": ["style.css"],
"run_at": "document_end",
"matches":["https://*.baidu.com/*"]
}
],
"permissions": [
"cookies",
"http://*/*",
"https://*/*",
"management",
"tabs",
"contextMenus"
]
}
body{
/*background-color: black;*/
/*filter: grayscale(1);*/
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment