Skip to content

Commit d852f7b

Browse files
authored
Merge pull request #8 from cloudoptlab/feat/1.4.1/white-list-ads-feature
Feat/1.4.1/white list ads feature
2 parents a358cd1 + 59028dd commit d852f7b

File tree

8 files changed

+47
-10
lines changed

8 files changed

+47
-10
lines changed

_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"popupAddBlackList": {
3535
"message": "Add to cloud security blacklist"
3636
},
37+
"popupAddWhiteListAds": {
38+
"message": "Add to whitelist-ads"
39+
},
3740
"popupCleanCache": {
3841
"message": "Clean up cache"
3942
},

_locales/ko/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"popupAddBlackList": {
3838
"message": "구름블랙리스트에 추가"
3939
},
40+
"popupAddWhiteListAds": {
41+
"message": "요격 광고에 추가"
42+
},
4043
"popupCleanCache": {
4144
"message": "캐시를 지우"
4245
},

_locales/zh_CN/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"popupAddBlackList": {
3838
"message": "添加到云安全黑名单"
3939
},
40+
"popupAddWhiteListAds": {
41+
"message": "添加到广告拦截白名单"
42+
},
4043
"popupCleanCache": {
4144
"message": "清理缓存"
4245
},

_locales/zh_TW/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"popupAddBlackList": {
3838
"message": "添加到雲安全黑名單"
3939
},
40+
"popupAddWhiteListAds": {
41+
"message": "添加到廣告攔截白名單"
42+
},
4043
"popupCleanCache": {
4144
"message": "清理緩存"
4245
},

js/cloudopt-option.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,12 @@
130130
theme: "mint",
131131
timeout: 1000
132132
}).show();
133-
refresh();
134-
cloudopt.message.send("refresh-config");
135-
$("#whiteListInput").val("");
133+
var config = cloudopt.config.get();
134+
cloudopt.config.set(config, function () {
135+
refresh();
136+
cloudopt.message.send("refresh-config");
137+
$("#whiteListInput").val("");
138+
});
136139
}
137140
})
138141
});
@@ -156,9 +159,12 @@
156159
theme: "mint",
157160
timeout: 1000
158161
}).show();
159-
refresh();
160-
cloudopt.message.send("refresh-config");
161-
$("#whiteListAdsInput").val("");
162+
var config = cloudopt.config.get();
163+
cloudopt.config.set(config, function () {
164+
refresh();
165+
cloudopt.message.send("refresh-config");
166+
$("#whiteListAdsInput").val("");
167+
});
162168
}
163169
})
164170
});
@@ -181,9 +187,12 @@
181187
theme: "mint",
182188
timeout: 1000
183189
}).show();
184-
refresh();
185-
cloudopt.message.send("refresh-config");
186-
$("#blackListInput").val("");
190+
var config = cloudopt.config.get();
191+
cloudopt.config.set(config, function () {
192+
refresh();
193+
cloudopt.message.send("refresh-config");
194+
$("#blackListInput").val("");
195+
});
187196
}
188197
})
189198
});

js/cloudopt-popup.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,19 @@ cloudopt.onFinish(function() {
153153
});
154154
})
155155

156+
$("#addWhiteListAds").click(function () {
157+
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
158+
const currentTab = tabs[0];
159+
cloudopt.config.fastAddWhiteListAds(currentTab.url)(type => {
160+
if (type === 'optionTipsDontDuplicate') {
161+
cloudopt.notification.info(cloudopt.i18n.get(type))
162+
} else if (type === 'optionTipsAddWhiteListAdsSuccess') {
163+
cloudopt.notification.success(cloudopt.i18n.get(type))
164+
} else if (type === 'optionTipsInputUrlisNull' || type === 'optionTipsInputUrlisError') {
165+
cloudopt.notification.error(cloudopt.i18n.get(type))
166+
}
167+
})
168+
});
169+
})
170+
156171
});

option.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ <h2 class="mdl-card__title-text" i18n="optionCustomRule">自定义规则列表</
394394
</div>
395395
</div>
396396

397-
<div class="mdl-card mdl-shadow--2dp" id="white-lis">
397+
<div class="mdl-card mdl-shadow--2dp" id="white-list">
398398
<div class="mdl-card__title">
399399
<h2 class="mdl-card__title-text" i18n="optionClassifyWhiteList">云安全白名单</h2>
400400
</div>

popup.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="more">
3636
<li class="mdl-menu__item" i18n="popupAddWhiteList" id="addWhiteList">添加到云安全白名单</li>
3737
<li class="mdl-menu__item" i18n="popupAddBlackList" id="addBlackList">添加到云安全黑名单</li>
38+
<li class="mdl-menu__item" i18n="popupAddWhiteListAds" id="addWhiteListAds">添加到广告拦截白名单</li>
3839
<li class="mdl-menu__item" id="cleanCache" i18n="popupCleanCache">清理缓存</li>
3940
<li class="mdl-menu__item" id="report" i18n="popupReport">举报</li>
4041
<li class="mdl-menu__item" id="evaluation" i18n="popupEvaluation">评价扩展</li>

0 commit comments

Comments
 (0)