mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Enforce blocking Firefox telemetry
This commit is contained in:
parent
c49c7e6afc
commit
c273db6832
@ -7,7 +7,7 @@ const cpuCount = require('os').cpus().length;
|
||||
const { isCI } = require('ci-info');
|
||||
const threads = isCI ? cpuCount : cpuCount / 2;
|
||||
|
||||
const { HOSTS, ADGUARD_FILTERS, PREDEFINED_WHITELIST } = require('./lib/reject-data-source');
|
||||
const { HOSTS, ADGUARD_FILTERS, PREDEFINED_WHITELIST, PREDEFINED_ENFORCED_BACKLIST } = require('./lib/reject-data-source');
|
||||
const { withBannerArray } = require('./lib/with-banner');
|
||||
const { compareAndWriteFile } = require('./lib/string-array-compare');
|
||||
|
||||
@ -53,7 +53,12 @@ const filterRuleWhitelistDomainSets = new Set(PREDEFINED_WHITELIST);
|
||||
if (foundDebugDomain) {
|
||||
shouldStop = true;
|
||||
}
|
||||
white.forEach(i => filterRuleWhitelistDomainSets.add(i));
|
||||
white.forEach(i => {
|
||||
if (PREDEFINED_ENFORCED_BACKLIST.some(j => i.endsWith(j))) {
|
||||
return;
|
||||
}
|
||||
filterRuleWhitelistDomainSets.add(i);
|
||||
});
|
||||
black.forEach(i => domainSets.add(i));
|
||||
} else {
|
||||
process.exit(1);
|
||||
@ -68,8 +73,18 @@ const filterRuleWhitelistDomainSets = new Set(PREDEFINED_WHITELIST);
|
||||
input => processFilterRules(input).then((i) => {
|
||||
if (i) {
|
||||
const { white, black } = i;
|
||||
white.forEach(i => filterRuleWhitelistDomainSets.add(i));
|
||||
black.forEach(i => filterRuleWhitelistDomainSets.add(i));
|
||||
white.forEach(i => {
|
||||
if (PREDEFINED_ENFORCED_BACKLIST.some(j => i.endsWith(j))) {
|
||||
return;
|
||||
}
|
||||
filterRuleWhitelistDomainSets.add(i)
|
||||
});
|
||||
black.forEach(i => {
|
||||
if (PREDEFINED_ENFORCED_BACKLIST.some(j => i.endsWith(j))) {
|
||||
return;
|
||||
}
|
||||
filterRuleWhitelistDomainSets.add(i)
|
||||
});
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
@ -262,7 +277,7 @@ const filterRuleWhitelistDomainSets = new Set(PREDEFINED_WHITELIST);
|
||||
}
|
||||
})();
|
||||
|
||||
function isInWhiteList (domain) {
|
||||
function isInWhiteList(domain) {
|
||||
for (const white of filterRuleWhitelistDomainSets) {
|
||||
if (domain === white || domain.endsWith(white)) {
|
||||
return true;
|
||||
|
||||
@ -16,7 +16,7 @@ const ADGUARD_FILTERS = [
|
||||
'https://raw.githubusercontent.com/easylist/easylist/gh-pages/easylist.txt',
|
||||
'https://secure.fanboy.co.nz/easylist.txt'
|
||||
],
|
||||
true
|
||||
false
|
||||
],
|
||||
// Easy Privacy
|
||||
[
|
||||
@ -26,7 +26,7 @@ const ADGUARD_FILTERS = [
|
||||
'https://raw.githubusercontent.com/easylist/easylist/gh-pages/easyprivacy.txt',
|
||||
'https://easylist-downloads.adblockplus.org/easyprivacy.txt'
|
||||
],
|
||||
true
|
||||
false
|
||||
],
|
||||
// AdGuard DNS Filter
|
||||
'https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt',
|
||||
@ -212,6 +212,11 @@ const PREDEFINED_WHITELIST = [
|
||||
'fastly-analytics.com'
|
||||
];
|
||||
|
||||
const PREDEFINED_ENFORCED_BACKLIST = [
|
||||
'telemetry.mozilla.org'
|
||||
];
|
||||
|
||||
module.exports.HOSTS = HOSTS;
|
||||
module.exports.ADGUARD_FILTERS = ADGUARD_FILTERS;
|
||||
module.exports.PREDEFINED_WHITELIST = PREDEFINED_WHITELIST;
|
||||
module.exports.PREDEFINED_ENFORCED_BACKLIST = PREDEFINED_ENFORCED_BACKLIST;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user