修改介绍文件

This commit is contained in:
xiananliu 2017-07-10 22:36:59 +08:00
parent 0f518853f1
commit 9927d235d4
5 changed files with 1372 additions and 6 deletions

1357
README.md

File diff suppressed because it is too large Load Diff

View File

@ -146,6 +146,7 @@ chrome.storage.sync.get({showImage: true}, function(items) {
}); });
// web请求监听最后一个参数表示阻塞式需单独声明权限webRequestBlocking // web请求监听最后一个参数表示阻塞式需单独声明权限webRequestBlocking
chrome.webRequest.onBeforeRequest.addListener(details => { chrome.webRequest.onBeforeRequest.addListener(details => {
// cancel 表示取消本次请求
if(!showImage && details.type == 'image') return {cancel: true}; if(!showImage && details.type == 'image') return {cancel: true};
// 简单的音视频检测 // 简单的音视频检测
// 大部分网站视频的type并不是media且视频做了防下载处理所以这里仅仅是为了演示效果无实际意义 // 大部分网站视频的type并不是media且视频做了防下载处理所以这里仅仅是为了演示效果无实际意义

View File

@ -33,14 +33,23 @@ document.addEventListener('DOMContentLoaded', function()
temp.innerHTML = css; temp.innerHTML = css;
console.log('已注入自定义CSS'); console.log('已注入自定义CSS');
// 屏蔽百度推广信息 // 屏蔽百度推广信息
$('[data-tuiguang]').parents('[data-click]').remove(); removeAdByJs();
// 这种必须用JS移除的广告一般会有延迟干脆每隔一段时间清楚一次
interval = setInterval(removeAdByJs, 2000);
// 重新搜索时页面不会刷新但是被注入的style会被移除所以需要重新执行 // 重新搜索时页面不会刷新但是被注入的style会被移除所以需要重新执行
temp.addEventListener('DOMNodeRemoved', function(e) temp.addEventListener('DOMNodeRemoved', function(e)
{ {
console.log('自定义CSS被移除重新注入'); console.log('自定义CSS被移除重新注入');
if(interval) clearInterval(interval);
fuckBaiduAD(); fuckBaiduAD();
}); });
} }
let interval = 0;
function removeAdByJs()
{
$('[data-tuiguang]').parents('[data-click]').remove();
}
fuckBaiduAD(); fuckBaiduAD();
initCustomPanel(); initCustomPanel();
initCustomEventListen(); initCustomEventListen();
@ -77,7 +86,7 @@ function injectCustomJs(jsPath)
// 放在页面不好看,执行完后移除掉 // 放在页面不好看,执行完后移除掉
this.parentNode.removeChild(this); this.parentNode.removeChild(this);
}; };
document.head.appendChild(temp); document.body.appendChild(temp);
} }
// 接收来自后台的消息 // 接收来自后台的消息

View File

@ -63,7 +63,7 @@
"tabs", // "tabs", //
"notifications", // "notifications", //
"webRequest", // web "webRequest", // web
"webRequestBlocking", "webRequestBlocking", // web
"storage", // "storage", //
"http://*/*", // executeScriptinsertCSS访 "http://*/*", // executeScriptinsertCSS访
"https://*/*" // executeScriptinsertCSS访 "https://*/*" // executeScriptinsertCSS访

View File

@ -26,6 +26,9 @@
</head> </head>
<body> <body>
<div class="center"><p>这是一个自定义的新标签页</p></div> <div class="center"><p>这是一个自定义的新标签页</p></div>
<div class="wrapper"><a href="https://www.baidu.com">百度</a></div> <div class="wrapper">
<a href="https://www.baidu.com">百度</a>
<a href="https://www.so.com">360搜索</a>
</div>
</body> </body>
</html> </html>