mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-03-13 11:44:12 +01:00
Added warning if some features of a API are disabled
This commit is contained in:
parent
d449e5f0c3
commit
73e5f5737b
@ -1476,6 +1476,10 @@
|
|||||||
"message": "All features of {api} are disabled but the protection is enabled.",
|
"message": "All features of {api} are disabled but the protection is enabled.",
|
||||||
"description": ""
|
"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": {
|
"sanitation_resolution.disableMainFlag": {
|
||||||
"message": "disable main flag",
|
"message": "disable main flag",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
@ -55,9 +55,12 @@
|
|||||||
{
|
{
|
||||||
name: "disabledFeatures",
|
name: "disabledFeatures",
|
||||||
check: function(errorCallback){
|
check: function(errorCallback){
|
||||||
const errorMessage = extension.getTranslation("sanitation_error.disabledFeatures");
|
const allErrorMessage = extension.getTranslation("sanitation_error.disabledFeatures");
|
||||||
function createErrorMessage(api){
|
const someErrorMessage = extension.getTranslation("sanitation_error.disabledSomeFeatures");
|
||||||
return errorMessage.replace(/{api}/g, extension.getTranslation("section_" + api.section));
|
function createErrorMessage(api, all = false){
|
||||||
|
return (all? allErrorMessage: someErrorMessage).replace(
|
||||||
|
/{api}/g,
|
||||||
|
extension.getTranslation("section_" + api.section));
|
||||||
}
|
}
|
||||||
const protectedFeatures = settings.getDefinition("protectedAPIFeatures");
|
const protectedFeatures = settings.getDefinition("protectedAPIFeatures");
|
||||||
const protectedFeaturesValue = protectedFeatures.get();
|
const protectedFeaturesValue = protectedFeatures.get();
|
||||||
@ -84,31 +87,39 @@
|
|||||||
{mainFlag: "protectScreen", section: "Screen-API"},
|
{mainFlag: "protectScreen", section: "Screen-API"},
|
||||||
].forEach(function(api){
|
].forEach(function(api){
|
||||||
if (settings.get(api.mainFlag) !== (api.mainFlagDisabledValue || false)){
|
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) &&
|
return protectedFeaturesValue.hasOwnProperty(key) &&
|
||||||
!protectedFeaturesValue[key];
|
!protectedFeaturesValue[key];
|
||||||
})){
|
})){
|
||||||
errorCallback({
|
const all = sectionKeys.every(function(key){
|
||||||
message: createErrorMessage(api),
|
return protectedFeaturesValue.hasOwnProperty(key) &&
|
||||||
severity: "high",
|
!protectedFeaturesValue[key];
|
||||||
resolutions: [
|
});
|
||||||
|
const resolutions = [
|
||||||
{
|
{
|
||||||
label: extension.getTranslation("sanitation_resolution.enableFeatures"),
|
label: extension.getTranslation("sanitation_resolution.enableFeatures"),
|
||||||
callback: function(){
|
callback: function(){
|
||||||
const protectedFeaturesValue = protectedFeatures.get();
|
const protectedFeaturesValue = protectedFeatures.get();
|
||||||
getSectionKeys(api.section).forEach(function(key){
|
sectionKeys.forEach(function(key){
|
||||||
protectedFeaturesValue[key] = true;
|
protectedFeaturesValue[key] = true;
|
||||||
});
|
});
|
||||||
protectedFeatures.set(protectedFeaturesValue);
|
protectedFeatures.set(protectedFeaturesValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
if (all){
|
||||||
|
resolutions.push({
|
||||||
label: extension.getTranslation("sanitation_resolution.disableMainFlag"),
|
label: extension.getTranslation("sanitation_resolution.disableMainFlag"),
|
||||||
callback: function(){
|
callback: function(){
|
||||||
settings.set(api.mainFlag, api.mainFlagDisabledValue || false);
|
settings.set(api.mainFlag, api.mainFlagDisabledValue || false);
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
]
|
}
|
||||||
|
errorCallback({
|
||||||
|
message: createErrorMessage(api, all),
|
||||||
|
severity: all? "high": "medium",
|
||||||
|
resolutions
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ Version 1.2:
|
|||||||
- always open options page in new tab
|
- always open options page in new tab
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
-
|
- added warning if some features of a API are disabled
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
-
|
-
|
||||||
|
Loading…
x
Reference in New Issue
Block a user