Skip to content

Commit 67c7265

Browse files
authored
Merge pull request #10 from cloudoptlab/feat/1.4.1/white-list-ads-feature
Feat/1.4.1/white list ads feature
2 parents d852f7b + cf0427e commit 67c7265

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

js/cloudopt-adblock.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ cloudopt.adblock = (function(cloudopt) {
2828

2929
function getConfig() {
3030
var cloudoptConfig = cloudopt.config.get();
31+
3132
var configuration = {
3233
filters: [101],
33-
whitelist: cloudoptConfig.whiteList.slice(),
34+
whitelist: cloudoptConfig.whitelistAds.slice(),
3435
rules: cloudoptConfig.customRule,
3536
filtersMetadataUrl: 'https://cdn.cloudopt.net/filters/chromium/filters.json',
3637
filterRulesUrl: 'https://cdn.cloudopt.net/filters/chromium/{filter_id}.txt'
3738
};
3839

3940
configuration.whitelist[configuration.whitelist.length] = "*.cloudopt.net";
41+
4042
if (cloudoptConfig.safePrivacy) {
4143
configuration.filters[configuration.filters.length] = 3;
4244
//configuration.filters[configuration.filters.length] = 4;
@@ -150,8 +152,8 @@ cloudopt.adblock = (function(cloudopt) {
150152
cloudopt.store.get("firstAutoAddWhiteList", function(value) {
151153
if (value == undefined || value == null) {
152154
cloudopt.store.set("firstAutoAddWhiteList", "true");
153-
cloudopt.config.autoAddWhiteList(function() {
154-
cloudopt.logger.debug('Add a white list.');
155+
cloudopt.config.autoAddWhiteListAds(function() {
156+
cloudopt.logger.debug('Add a whiteList-ads.');
155157
refreshConfig();
156158
});
157159
}

js/cloudopt-core.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,11 @@ cloudopt.config = (function (cloudopt) {
715715
}
716716

717717
/**
718-
* Add whiteList for config
718+
* Add whiteList-ads for config
719719
*
720720
* @param callback callback when succeed
721721
*/
722-
function autoAddWhiteList(callback) {
722+
function autoAddWhiteListAds(callback) {
723723
var fileName = "/whitelist/";
724724
switch (cloudopt.getLanguage()) {
725725
case "zh-CN":
@@ -730,15 +730,13 @@ cloudopt.config = (function (cloudopt) {
730730
$.getJSON(fileName, function (data) {
731731
var config = cloudopt.config.get();
732732
$.each(data, function (index, obj) {
733-
config.whiteList[config.whiteList.length] = obj.host;
733+
config.whiteListAds[config.whiteListAds.length] = obj.host;
734734
});
735735
cloudopt.config.set(config, function () {
736736
cloudopt.message.send("refresh-config");
737737
callback();
738738
});
739739
});
740-
741-
742740
}
743741

744742
/**
@@ -802,7 +800,7 @@ cloudopt.config = (function (cloudopt) {
802800
set: set,
803801
refresh: refresh,
804802
activateEquipment: activateEquipment,
805-
autoAddWhiteList: autoAddWhiteList,
803+
autoAddWhiteListAds: autoAddWhiteListAds,
806804
fastAddWhiteList: fastAddWhiteList,
807805
fastAddWhiteListAds: fastAddWhiteListAds,
808806
fastAddBlackList: fastAddBlackList,
@@ -980,6 +978,9 @@ cloudopt.grade = (function (cloudopt) {
980978
if (config.whiteList.indexOf(item.host) > -1 && item.safe < 0) {
981979
item.safe = 0;
982980
}
981+
if (config.whiteListAds.indexOf(item.host) > -1 && item.safe < 0) {
982+
item.safe = 0;
983+
}
983984
/*if in black list*/
984985
if (config.blackList.some(e => e === item.host)) {
985986
item.safe = -1;
@@ -1010,6 +1011,9 @@ cloudopt.grade = (function (cloudopt) {
10101011
if (config.whiteList.indexOf(result.host) > -1 && result.safe == -1) {
10111012
result.safe = 0;
10121013
}
1014+
if (config.whiteListAds.indexOf(result.host) > -1 && result.safe == -1) {
1015+
result.safe = 0;
1016+
}
10131017
if (data.result.host != "") {
10141018
result.date = new Date().getTime();
10151019
cloudopt.store.set(website, result);
@@ -1062,7 +1066,7 @@ cloudopt.init = (function (cloudopt) {
10621066
url = tabArray[tabArray.length - 1].url;
10631067
host = cloudopt.utils.getHost(url);
10641068
// cloudopt.browserIconChange.normal();
1065-
if (tabArray[tabArray.length - 1].url.indexOf("file://") == 0 || tabArray[tabArray.length - 1].url.indexOf("chrome-extension://") == 0 || tabArray[tabArray.length - 1].url.indexOf("chrome://") == 0 || cloudopt.config.get().whiteList.indexOf(host) > -1) {
1069+
if (tabArray[tabArray.length - 1].url.indexOf("file://") == 0 || tabArray[tabArray.length - 1].url.indexOf("chrome-extension://") == 0 || tabArray[tabArray.length - 1].url.indexOf("chrome://") == 0 || cloudopt.config.get().whiteList.indexOf(host) > -1 || cloudopt.config.get().whiteListAds.indexOf(host) > -1) {
10661070
cloudopt.browserIconChange.gray();
10671071
return;
10681072
}

js/cloudopt-option.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
$("#whiteListAdsAdd").click(function() {
144144
const text = $("#whiteListAdsInput").val();
145145
const config = cloudopt.config.get();
146-
console.log(config, 'config')
147146
cloudopt.config.fastAddWhiteListAds(cloudopt.utils.getHost(text))(type => {
148147
if (type === 'optionTipsDontDuplicate' || type === 'optionTipsInputUrlisNull' || type === 'optionTipsInputUrlisError') {
149148
new Noty({

0 commit comments

Comments
 (0)