1
0
mirror of https://gitee.com/bitdance-team/chrome-extension synced 2025-01-10 13:48:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

Merge branch 'feat-remove-google-ads' into feat-advanced-search

This commit is contained in:
程序员小墨 2022-02-09 18:26:19 +08:00
commit 989a3cb2c3
4 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,5 @@
console.log("[BitDance extension] 学生助手插件 - it1352阅读全文自动展开模块加载成功");
window.onload = () => {
$('.arc-body-main').height("initial")
$('.arc-body-main-more').remove()
}

View File

@ -0,0 +1,20 @@
// refer: https://www.it1352.com/1996113.html
chrome.webRequest.onBeforeRequest.addListener(
function (details) {
let isBlock = false
|| details.initiator === "https://googleads.g.doubleclick.net"
|| details.initiator.indexOf("googleads.g.doubleclick.net") != -1
|| details.url.indexOf("googleads.g.doubleclick.net") != -1
|| details.url.indexOf("pagead2.googlesyndication.com") != -1
|| details.url.indexOf("pagead2.googlesyndication.com") != -1
|| details.url.indexOf("partner.googleadservices.com") != -1
|| details.url.indexOf("adservice.google.com") != -1
|| details.url.indexOf("googleads") != -1
|| details.url.indexOf("adsbygoogle") != -1
if (isBlock) // 拦截后打印到控制台显示
console.log(isBlock ? "block" : "allow", details)
return { cancel: isBlock };
},
{ urls: ["<all_urls>"] },
["blocking"]
);

View File

@ -0,0 +1,24 @@
// console.log("[BitDance extension] 学生助手插件 - 删除谷歌广告模块加载成功");
// window.onload = () => {
// // 基本上 background_preventAdsScript.js 可以在源头拦截所有广告,所以下面的代码正常情况可以不用,除非用户未授权所需权限
// // 谷歌广告的通用特性是几层ins中间包含iframe最外层ins有adsbygoogle这个class所以上来就给他干掉
// var insList = document.getElementsByTagName("ins");
// for (var i = insList.length - 1; i >= 0; i--) {
// ins = insList[i];
// if (ins.classList.contains("adsbygoogle")) {
// console.log("发现google广告ins容器删除");
// ins.parentNode.removeChild(ins);
// }
// }
// // 如果不含ins但是能够断定是广告iframe也干掉他
// var iframes = document.getElementsByTagName("iframe");
// for (var i = iframes.length - 1; i >= 0; i--) {
// if (iframes[i].src.indexOf("googleads.g.doubleclick.net") > -1) {
// console.log("发现google广告删除");
// iframes[i].parentNode.removeChild(iframes[i]);
// }
// }
// }

View File

@ -15,6 +15,7 @@
"scripts": [
"assets/js/lib/jquery.min.js",
"assets/js/background.js",
"assets/js/remove-google-ads/background_preventAdsScript.js",
"assets/html/pomodoro/background.js",
"assets/js/advanced-search/background.js",
"assets/html/screenshot/background.js"
@ -38,6 +39,17 @@
"run_at": "document_start"
},
{
"_______commit": "屏蔽Google广告模块",
"matches": [
"*://*/*"
],
"js": [
"assets/js/remove-google-ads/removeAds.js"
],
"run_at": "document_start"
},
{
"_______commit": "自动展开模块",
"matches": [
"*://blog.csdn.net/*"
],
@ -48,6 +60,17 @@
"run_at": "document_start"
},
{
"_______commit": "自动展开模块",
"matches": [
"*://www.it1352.com/*"
],
"js": [
"assets/js/expand-full-text/www.it1352.com.js"
],
"run_at": "document_start"
},
{
"_______commit": "自动搜索模块",
"matches": [
"*://fanyi.qq.com/*",
"*://baike.baidu.com/*",
@ -85,8 +108,10 @@
"contextMenus",
"storage",
"webRequest",
"webRequestBlocking",
"tabs",
"activeTab",
"notifications"
"notifications",
"<all_urls>"
]
}