Implemented an option to block unhandled Google Fonts requests

This commit is contained in:
nobody 2020-07-03 08:37:00 +02:00
parent eb1a34dce7
commit 8c9d5837ad
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
40 changed files with 320 additions and 3 deletions

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "HTML-Filter für diese Domains anwenden:",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "Blockiere Google Fonts",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "Blockiere alle Anfragen an \"fonts.googleapis.com\".",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "Apply HTML filter for these domains:",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "Block Google Fonts",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "Block all requests to \"fonts.googleapis.com\".",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "Apply HTML filter for these domains:",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "Bruk HTML-filter på disse domenene:",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "Zastosuj filtr HTML dla tych domen:",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "Bu etki alanları için HTML filtresini uygula:",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -134,5 +134,13 @@
"htmlFilterDomainsTitleInclude": {
"message": "",
"description": "Apply HTML filter for these domains:"
},
"blockGoogleFontsTitle": {
"message": "",
"description": "Block Google Fonts"
},
"blockGoogleFontsDescription": {
"message": "",
"description": "If requests for missing resources are allowed, connections to \"fonts.googleapis.com\" are not blocked. Enable this option to block these requests."
}
}

View File

@ -73,7 +73,8 @@ const Setting = {
'LOGGING': 'enableLogging',
'DOMAINS_MANIPULATE_DOM': 'domainsManipulateDOM',
'STATISTIC_DATA': 'statisticData',
'NEGATE_HTML_FILTER_LIST': 'negateHtmlFilterList'
'NEGATE_HTML_FILTER_LIST': 'negateHtmlFilterList',
'BLOCK_GOOGLE_FONTS': 'blockGoogleFonts'
};
const WebRequest = {

View File

@ -34,6 +34,18 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) {
validCandidate = requestAnalyzer.isValidCandidate(requestDetails, tab);
if (requestDetails.url.startsWith('https://fonts.googleapis.com/css?family')) {
if(interceptor.blockGoogleFonts) {
return {
'cancel': true
};
} else {
return {
'cancel': false
};
}
}
if (!validCandidate) {
return {
@ -119,6 +131,10 @@ interceptor._handleStorageChanged = function (changes) {
if (Setting.BLOCK_MISSING in changes) {
interceptor.blockMissing = changes.blockMissing.newValue;
}
if (Setting.BLOCK_GOOGLE_FONTS in changes) {
interceptor.blockGoogleFonts = changes.blockGoogleFonts.newValue;
}
};
/**
@ -131,6 +147,7 @@ interceptor.taintedDomains = {};
interceptor.amountInjected = 0;
interceptor.xhrTestDomain = Address.DECENTRALEYES;
interceptor.blockMissing = false;
interceptor.blockGoogleFonts = true;
interceptor.relatedSettings = [];
@ -143,6 +160,7 @@ chrome.storage.sync.get(interceptor.relatedSettings, function (items) {
interceptor.amountInjected = items.amountInjected || 0;
interceptor.xhrTestDomain = items.xhrTestDomain || Address.DECENTRALEYES;
interceptor.blockMissing = items.blockMissing || false;
interceptor.blockGoogleFonts = items.blockGoogleFonts || true;
});
/**

View File

@ -41,7 +41,8 @@ main._initializeSettings = function () {
[Setting.WHITELISTED_DOMAINS]: {},
[Setting.LOGGING]: false,
[Setting.DOMAINS_MANIPULATE_DOM]: {},
[Setting.NEGATE_HTML_FILTER_LIST]: false
[Setting.NEGATE_HTML_FILTER_LIST]: false,
[Setting.BLOCK_GOOGLE_FONTS]: true
};
chrome.storage.sync.get(settingDefaults, function (items) {

View File

@ -48,6 +48,16 @@
</div>
<div class="description-option" data-i18n-content="blockMissingDescription"></div>
</section>
<section id="block-google-fonts" class="option">
<div class="title-option">
<label class="b-contain">
<input data-option="blockGoogleFonts" type="checkbox">
<span data-i18n-content="blockGoogleFontsTitle">Block Google Fonts</span>
<div class="b-input"></div>
</label>
</div>
<div class="description-option" data-i18n-content="blockGoogleFontsDescription">If you use the rules of the rule generator, requests to "fonts.googleapis.com" are allowed to substitute "Google Material Icons" automatically. If you want to block the other requests, enable this option.</div>
</section>
<section class="option">
<div class="title-option">
<label class="b-contain">

View File

@ -65,6 +65,7 @@ options._renderOptionsPanel = function () {
elements.whitelistedDomains.value = domainWhitelist;
elements.domainsManipulateDOM.value = domainHtmlFilter;
elements.negateHtmlFilterList.checked = options._optionValues.negateHtmlFilterList;
elements.blockGoogleFonts.checked = options._optionValues.blockGoogleFonts;
options._registerOptionChangedEventListeners(elements);
options._registerMiscellaneousEventListeners();
@ -77,6 +78,8 @@ options._renderOptionsPanel = function () {
options._renderLocaleNotice();
}
options._displayBlockGoogleFonts(options._optionValues.blockMissing);
if(elements.negateHtmlFilterList.checked === true) {
document.getElementById('html-filter-domains-title-include').style.display = "none";
document.getElementById('html-filter-domains-title-exclude').style.display = "block";
@ -121,6 +124,7 @@ options._registerOptionChangedEventListeners = function (elements) {
elements.whitelistedDomains.addEventListener('keyup', options._onOptionChanged);
elements.domainsManipulateDOM.addEventListener('keyup', options._onOptionChanged);
elements.negateHtmlFilterList.addEventListener('change', options._onOptionChanged);
elements.blockGoogleFonts.addEventListener('change', options._onOptionChanged);
let type = elements.ruleSets;
for(let i = 0; i < type.length; i++) {
type[i].addEventListener('change', options._openRuleSet);
@ -172,7 +176,8 @@ options._getOptionElements = function () {
['ruleSets']: document.getElementsByName("rule-sets"),
['copyRuleSet']: document.getElementById("button-copy-rule-set"),
[Setting.NEGATE_HTML_FILTER_LIST]: options._getOptionElement(Setting.NEGATE_HTML_FILTER_LIST),
[Setting.DOMAINS_MANIPULATE_DOM]: options._getOptionElement(Setting.DOMAINS_MANIPULATE_DOM)
[Setting.DOMAINS_MANIPULATE_DOM]: options._getOptionElement(Setting.DOMAINS_MANIPULATE_DOM),
[Setting.BLOCK_GOOGLE_FONTS]: options._getOptionElement(Setting.BLOCK_GOOGLE_FONTS)
};
return optionElements;
@ -255,8 +260,10 @@ options._onOptionChanged = function ({target}) {
if (optionValue === true) {
options._renderBlockMissingNotice();
options._displayBlockGoogleFonts(true);
} else {
options._hideBlockMissingNotice();
options._displayBlockGoogleFonts(false);
}
}
@ -361,6 +368,13 @@ options._updatesDomainLists = function(changes) {
}
};
options._displayBlockGoogleFonts = function(value) {
if (value === true) {
document.getElementById('block-google-fonts').style.display = "none";
} else {
document.getElementById('block-google-fonts').style.display = "block";
}
};
/**
* Initializations

View File

@ -30,6 +30,7 @@
<li>Small cosmetic improvements in the popup</li>
<li>Added: slick-carousel/slick v1.9.0 (<a href="https://addons.mozilla.org/de/firefox/addon/localcdn-fork-of-decentraleyes/reviews/1563434/">review</a>)</li>
<li>Added: Materialize (JS & CSS) v100.2 and v1.0.0 (<a href="https://codeberg.org/nobody/LocalCDN/issues/47">#47</a>)</li>
<li>Implemented: Option to block unhandled Google Fonts requests</li>
</ul>
<div class="topic-label">
Generate rule sets for uBlock or uMatrix