mirror of
https://gitee.com/bitdance-team/chrome-extension
synced 2025-01-10 13:48:14 +08:00
AdsBlock代码小调整
This commit is contained in:
parent
253eeeaf9b
commit
55c2f64ed6
@ -52,7 +52,6 @@ $(function() {
|
||||
// 页面加载时,更新界面开关状态
|
||||
chrome.storage.sync.get('State_AdsBlock', function(budget) {
|
||||
btnGoogleAds.checked = !budget.State_AdsBlock;
|
||||
chrome.extension.getBackgroundPage().updateAdsBlockStatus(!btnGoogleAds.checked);
|
||||
});
|
||||
|
||||
// 点击开关时存储按钮状态并刷新页面
|
||||
|
@ -2,7 +2,6 @@ var AdsBlockStatus = true;
|
||||
// refer: https://www.it1352.com/1996113.html
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function (details) {
|
||||
console.log("AdsBlock Status: ", AdsBlockStatus);
|
||||
|
||||
if (!AdsBlockStatus)
|
||||
return { cancel: false }; // 如果没有开启此功能,不处理
|
||||
@ -33,6 +32,7 @@ chrome.webRequest.onBeforeRequest.addListener(
|
||||
// 由于上方拦截函数不可以是异步函数,所以设置变更后需要及时调用此函数
|
||||
var updateAdsBlockStatus = (status) => {
|
||||
AdsBlockStatus = !!status;
|
||||
console.log("AdsBlock Status: ", AdsBlockStatus);
|
||||
}
|
||||
|
||||
// 插件刚开始加载时,先读取一次状态
|
||||
|
Loading…
Reference in New Issue
Block a user