From f1fb6c9a17ac18c2d619af9656b3099971250449 Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 27 Jul 2022 18:22:49 +0200 Subject: [PATCH] Chromium: Remove option to block Google Fonts (#1085) --- core/interceptor.js | 7 ------- core/request-analyzer.js | 6 ------ core/state-manager.js | 3 +++ modules/internal/rule-generator.js | 5 +++++ pages/options/options-advanced.js | 1 + pages/popup/popup.js | 1 + pages/updates/updates.html | 1 + 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/core/interceptor.js b/core/interceptor.js index 2ee1407c..fe72c264 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -76,13 +76,6 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) { 'cancel': false }; } - } else if (!BrowserType.FIREFOX && (isGoogleFont || isGoogleMaterialIcons)) { - initiatorDomain = helpers.extractDomainFromUrl(tab.url, true); - isListed = helpers.checkAllowlisted(initiatorDomain, interceptor.allowedDomainsGoogleFonts); - // Check if the website is allowed to load Google Fonts - return { - 'cancel': interceptor.blockGoogleFonts === true && isListed === false - }; } if (targetDetails['result'] === false) { diff --git a/core/request-analyzer.js b/core/request-analyzer.js index c3a16bde..b945ac1f 100644 --- a/core/request-analyzer.js +++ b/core/request-analyzer.js @@ -57,12 +57,6 @@ requestAnalyzer.isValidCandidate = function (requestDetails, tabDetails) { log.append(tabDetails.url, requestDetails.url, LogString.FONT_AWESOME, true); return false; } - if (requestAnalyzer.isGoogleMaterialIcons(requestedDomain, requestDetails.url)) { - // also valid for Google Material icons - console.warn(`${LogString.PREFIX} ${LogString.GOOGLE_MATERIAL_ICONS}`); - log.append(tabDetails.url, requestDetails.url, LogString.GOOGLE_MATERIAL_ICONS, true); - return false; - } } // Ignore requests if website is 'yandex.com' and CDN is 'yastatic.net', because website and CDN are the same. diff --git a/core/state-manager.js b/core/state-manager.js index 10fbe903..eb5c0040 100644 --- a/core/state-manager.js +++ b/core/state-manager.js @@ -294,6 +294,9 @@ stateManager.logging = false; for (let mapping in mappings.cdn) { let supportedHost = Address.ANY_PROTOCOL + mapping + Address.ANY_PATH; + if (!BrowserType.FIREFOX && (mapping === 'fonts.gstatic.com' || mapping === 'fonts.googleapis.com')) { + continue; + } stateManager.validHosts.push(supportedHost); } diff --git a/modules/internal/rule-generator.js b/modules/internal/rule-generator.js index a89d9baa..f9f3705c 100644 --- a/modules/internal/rule-generator.js +++ b/modules/internal/rule-generator.js @@ -38,6 +38,11 @@ ruleGenerator.openRuleSet = function ({target}) { textArea.style.display = 'block'; btnCopy.style.display = 'block'; + if (!BrowserType.FIREFOX) { + delete urls['fonts.googleapis.com']; + delete urls['fonts.gstatic.com']; + } + for (const domain in urls) { if (key === 'uMatrix') { content += `* ${domain} script allow\n`; diff --git a/pages/options/options-advanced.js b/pages/options/options-advanced.js index daa1ea7f..cdb5bd20 100644 --- a/pages/options/options-advanced.js +++ b/pages/options/options-advanced.js @@ -59,6 +59,7 @@ optionsAdvanced.init = function (opt) { if (BrowserType.CHROMIUM) { document.getElementById('html-filter-div').style.display = 'none'; + document.getElementById('block-google-fonts').style.display = 'none'; } document.getElementById('last-mapping-update').textContent += ` ${mappings.lastMappingUpdate}`; diff --git a/pages/popup/popup.js b/pages/popup/popup.js index ac15bc4b..53d40b59 100644 --- a/pages/popup/popup.js +++ b/pages/popup/popup.js @@ -49,6 +49,7 @@ popup._renderContents = function () { if (BrowserType.CHROMIUM) { document.getElementById('div-manipulateDOM').hidden = true; + document.getElementById('div-google-fonts').hidden = true; } }; diff --git a/pages/updates/updates.html b/pages/updates/updates.html index 0ad4a577..f772e9d4 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -39,6 +39,7 @@

Improved