Initial commit to add wildcard for Google Fonts and HTML filters (#613)
This commit is contained in:
parent
67b67bbd68
commit
651d19bfa6
|
@ -46,13 +46,16 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) {
|
|||
|
||||
|
||||
if (Regex.GOOGLE_FONTS.test(requestDetails.url)) {
|
||||
let initiatorDomain = helpers.extractDomainFromUrl(tab.url, true);
|
||||
let initiatorDomain, isListed;
|
||||
|
||||
initiatorDomain = helpers.extractDomainFromUrl(tab.url, true);
|
||||
isListed = helpers.checkAllowlisted(initiatorDomain, interceptor.allowedDomainsGoogleFonts);
|
||||
// Check if the website is allowed to load Google Fonts
|
||||
if (interceptor.blockGoogleFonts === true && !interceptor.allowedDomainsGoogleFonts[initiatorDomain]) {
|
||||
if (interceptor.blockGoogleFonts === true && isListed === false) {
|
||||
return {
|
||||
'cancel': true
|
||||
};
|
||||
} else if (interceptor.blockGoogleFonts === false || interceptor.allowedDomainsGoogleFonts[initiatorDomain]) {
|
||||
} else if (interceptor.blockGoogleFonts === false || isListed === true) {
|
||||
return {
|
||||
'cancel': false
|
||||
};
|
||||
|
|
|
@ -54,11 +54,11 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
|
|||
return MessageResponse.SYNCHRONOUS;
|
||||
|
||||
case 'domain:fetch-is-allowlisted':
|
||||
sendResponse({'value': Boolean(helpers.checkAllowlisted(value))});
|
||||
sendResponse({'value': Boolean(helpers.checkAllowlisted(value, requestAnalyzer.allowlistedDomains))});
|
||||
return MessageResponse.SYNCHRONOUS;
|
||||
|
||||
case 'domain:fetch-is-manipulateDOM':
|
||||
sendResponse({'value': Boolean(requestAnalyzer.domainsManipulateDOM[value])});
|
||||
sendResponse({'value': Boolean(helpers.checkAllowlisted(value, requestAnalyzer.domainsManipulateDOM))});
|
||||
return MessageResponse.SYNCHRONOUS;
|
||||
|
||||
case 'allowlist:add-domain':
|
||||
|
|
|
@ -39,7 +39,7 @@ requestAnalyzer.isValidCandidate = function (requestDetails, tabDetails) {
|
|||
initiatorDomain = Address.EXAMPLE;
|
||||
}
|
||||
|
||||
isAllowlisted = helpers.checkAllowlisted(initiatorDomain);
|
||||
isAllowlisted = helpers.checkAllowlisted(initiatorDomain, requestAnalyzer.allowlistedDomains);
|
||||
if (isAllowlisted) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ requestSanitizer._stripMetadata = function (requestDetails) {
|
|||
|
||||
sensitiveHeaders = [Header.COOKIE, Header.ORIGIN, Header.REFERER];
|
||||
initiatorDomain = helpers.extractDomainFromUrl(requestDetails.initiator, true);
|
||||
allowlistedDomains = helpers.checkAllowlisted(initiatorDomain);
|
||||
allowlistedDomains = helpers.checkAllowlisted(initiatorDomain, requestAnalyzer.allowlistedDomains);
|
||||
|
||||
if (allowlistedDomains) {
|
||||
return {
|
||||
|
|
|
@ -230,7 +230,7 @@ stateManager._domainIsListed = function (domain, listname) {
|
|||
allowlistRecord = requestAnalyzer.domainsManipulateDOM[domain];
|
||||
isAllowlisted = Boolean(allowlistRecord);
|
||||
} else {
|
||||
allowlistRecord = helpers.checkAllowlisted(domain);
|
||||
allowlistRecord = helpers.checkAllowlisted(domain, requestAnalyzer.allowlistedDomains);
|
||||
isAllowlisted = Boolean(allowlistRecord);
|
||||
}
|
||||
return isAllowlisted;
|
||||
|
|
|
@ -133,8 +133,8 @@ helpers.getWildcard = function (initiatorDomain) {
|
|||
|
||||
};
|
||||
|
||||
helpers.checkAllowlisted = function (domain) {
|
||||
let domainWithoutPrefix, wildcard, list;
|
||||
helpers.checkAllowlisted = function (domain, list) {
|
||||
let domainWithoutPrefix, wildcard;
|
||||
|
||||
if (domain === null) {
|
||||
return false;
|
||||
|
@ -144,7 +144,6 @@ helpers.checkAllowlisted = function (domain) {
|
|||
domainWithoutPrefix = domain.slice(Address.WWW_PREFIX.length);
|
||||
}
|
||||
wildcard = helpers.getWildcard(domain);
|
||||
list = requestAnalyzer.allowlistedDomains;
|
||||
|
||||
return Boolean(list[domain] || list[domainWithoutPrefix] || list[wildcard] || list[domainWithoutPrefix]);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue