diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 99b3771..45d2be3 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1476,6 +1476,10 @@ "message": "All features of {api} are disabled but the protection is enabled.", "description": "" }, + "sanitation_error.disabledSomeFeatures": { + "message": "Some features of {api} are disabled. This should only be done in testing or if you really know what the features are doing.", + "description": "" + }, "sanitation_resolution.disableMainFlag": { "message": "disable main flag", "description": "" diff --git a/options/sanitationRules.js b/options/sanitationRules.js index f522691..08e839d 100644 --- a/options/sanitationRules.js +++ b/options/sanitationRules.js @@ -55,9 +55,12 @@ { name: "disabledFeatures", check: function(errorCallback){ - const errorMessage = extension.getTranslation("sanitation_error.disabledFeatures"); - function createErrorMessage(api){ - return errorMessage.replace(/{api}/g, extension.getTranslation("section_" + api.section)); + const allErrorMessage = extension.getTranslation("sanitation_error.disabledFeatures"); + const someErrorMessage = extension.getTranslation("sanitation_error.disabledSomeFeatures"); + function createErrorMessage(api, all = false){ + return (all? allErrorMessage: someErrorMessage).replace( + /{api}/g, + extension.getTranslation("section_" + api.section)); } const protectedFeatures = settings.getDefinition("protectedAPIFeatures"); const protectedFeaturesValue = protectedFeatures.get(); @@ -84,31 +87,39 @@ {mainFlag: "protectScreen", section: "Screen-API"}, ].forEach(function(api){ if (settings.get(api.mainFlag) !== (api.mainFlagDisabledValue || false)){ - if (getSectionKeys(api.section).every(function(key){ + const sectionKeys = getSectionKeys(api.section); + if (sectionKeys.some(function(key){ return protectedFeaturesValue.hasOwnProperty(key) && !protectedFeaturesValue[key]; })){ + const all = sectionKeys.every(function(key){ + return protectedFeaturesValue.hasOwnProperty(key) && + !protectedFeaturesValue[key]; + }); + const resolutions = [ + { + label: extension.getTranslation("sanitation_resolution.enableFeatures"), + callback: function(){ + const protectedFeaturesValue = protectedFeatures.get(); + sectionKeys.forEach(function(key){ + protectedFeaturesValue[key] = true; + }); + protectedFeatures.set(protectedFeaturesValue); + } + }, + ]; + if (all){ + resolutions.push({ + label: extension.getTranslation("sanitation_resolution.disableMainFlag"), + callback: function(){ + settings.set(api.mainFlag, api.mainFlagDisabledValue || false); + } + }); + } errorCallback({ - message: createErrorMessage(api), - severity: "high", - resolutions: [ - { - label: extension.getTranslation("sanitation_resolution.enableFeatures"), - callback: function(){ - const protectedFeaturesValue = protectedFeatures.get(); - getSectionKeys(api.section).forEach(function(key){ - protectedFeaturesValue[key] = true; - }); - protectedFeatures.set(protectedFeaturesValue); - } - }, - { - label: extension.getTranslation("sanitation_resolution.disableMainFlag"), - callback: function(){ - settings.set(api.mainFlag, api.mainFlagDisabledValue || false); - } - }, - ] + message: createErrorMessage(api, all), + severity: all? "high": "medium", + resolutions }); } } diff --git a/releaseNotes.txt b/releaseNotes.txt index 1d9067d..9d887bd 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -4,7 +4,7 @@ Version 1.2: - always open options page in new tab new features: - - + - added warning if some features of a API are disabled fixes: -