mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2024-12-22 16:12:13 +01:00
Check HTML filter improved
This commit is contained in:
parent
1be3c1cf6d
commit
47d2956824
@ -36,22 +36,14 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
|
||||
return;
|
||||
}
|
||||
if (details.statusCode === 200) {
|
||||
let initiatorDomain, listedToManipulateDOM, negateHtmlFilter, filtering, header;
|
||||
let initiatorDomain, header;
|
||||
|
||||
initiatorDomain = helpers.extractDomainFromUrl(details.url, true) || Address.EXAMPLE;
|
||||
listedToManipulateDOM = stateManager._domainIsListed(initiatorDomain, 'manipulate-dom');
|
||||
negateHtmlFilter = stateManager.getInvertOption;
|
||||
|
||||
if ((negateHtmlFilter || listedToManipulateDOM) && !(negateHtmlFilter && listedToManipulateDOM)) {
|
||||
filtering = true;
|
||||
} else {
|
||||
filtering = false;
|
||||
}
|
||||
|
||||
// by Jaap (https://gitlab.com/Jaaap)
|
||||
header = details.responseHeaders.find((h) => h.name.toLowerCase() === 'content-type');
|
||||
|
||||
if (header && filtering) {
|
||||
if (header && manipulateDOM.checkHtmlFilterEnabled(initiatorDomain)) {
|
||||
|
||||
let mimeType, isAllowlisted;
|
||||
|
||||
@ -151,6 +143,22 @@ manipulateDOM._searchCharset = function (str, charset) {
|
||||
return str;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Public Methods
|
||||
*/
|
||||
|
||||
manipulateDOM.checkHtmlFilterEnabled = function (url) {
|
||||
let listedToManipulateDOM, negateHtmlFilter;
|
||||
listedToManipulateDOM = stateManager._domainIsListed(url, 'manipulate-dom');
|
||||
negateHtmlFilter = stateManager.getInvertOption;
|
||||
|
||||
if ((negateHtmlFilter || listedToManipulateDOM) && !(negateHtmlFilter && listedToManipulateDOM)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializations
|
||||
*/
|
||||
|
@ -31,7 +31,7 @@ var stateManager = {};
|
||||
*/
|
||||
|
||||
stateManager.registerInjection = function (tabIdentifier, injection, url) {
|
||||
let injectionIdentifier, registeredTab, injectionCount, missingCount, initiatorDomain, listedToManipulateDOM;
|
||||
let injectionIdentifier, registeredTab, injectionCount, missingCount, initiatorDomain, htmlFilterIsActive;
|
||||
|
||||
if (injection['result'] !== false) {
|
||||
injectionIdentifier = injection.source + injection.path;
|
||||
@ -40,7 +40,7 @@ stateManager.registerInjection = function (tabIdentifier, injection, url) {
|
||||
}
|
||||
|
||||
initiatorDomain = helpers.extractDomainFromUrl(url, true) || Address.EXAMPLE;
|
||||
listedToManipulateDOM = stateManager._domainIsListed(initiatorDomain, 'manipulate-dom');
|
||||
htmlFilterIsActive = manipulateDOM.checkHtmlFilterEnabled(initiatorDomain);
|
||||
|
||||
injectionCount = Object.keys(registeredTab.injections).length || 0;
|
||||
missingCount = registeredTab.missing || 0;
|
||||
@ -54,7 +54,7 @@ stateManager.registerInjection = function (tabIdentifier, injection, url) {
|
||||
if (stateManager.showIconBadge === true) {
|
||||
if (missingCount > 0 && stateManager.changeBadgeColorMissingResources) {
|
||||
wrappers.setBadgeColoring(tabIdentifier, BadgeSettingMissingResource.TYPE);
|
||||
} else if (listedToManipulateDOM) {
|
||||
} else if (htmlFilterIsActive) {
|
||||
wrappers.setBadgeColoring(tabIdentifier, BadgeSettingHTMLFilter.TYPE);
|
||||
} else {
|
||||
wrappers.setBadgeColoring(tabIdentifier, BadgeSetting.TYPE);
|
||||
|
Loading…
Reference in New Issue
Block a user