diff --git a/.vscode/settings.json b/.vscode/settings.json index c748d82..ed9cc7b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,7 @@ "cSpell.words": [ "Blockiermodi", "Blockiermodus", + "Captcha", "Ignorierliste", "Maleficient", "Nachfrageverweigerungsmodus", diff --git a/_locales/de/messages.json b/_locales/de/messages.json index c592449..990284d 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -865,6 +865,10 @@ "message": "Es werden window.opener und window.name beschützt. Dies kann manche Webseiten unbrauchbar machen.", "description": "" }, + "protectWindow_askReCaptchaException": { + "message": "Wenn die Window-API beschützt wird, funktioniert reCAPTCHA nicht mehr. Wollen Sie dafür eine Ausnahme hinzufügen?", + "description": "" + }, "theme_title": { "message": "Theme", diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 716259b..0650127 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -857,13 +857,17 @@ }, "protectWindow_title": { - "message": "Protect Window API", + "message": "Protect window API", "description": "" }, "protectWindow_description": { "message": "window.opener and window.name will be protected. This can render some web pages unusable.", "description": "" }, + "protectWindow_askReCaptchaException": { + "message": "Protecting the window API breaks reCAPTCHA. Do you want to add an exception for it?", + "description": "" + }, "theme_title": { "message": "Theme", diff --git a/options/options.js b/options/options.js index 5707d52..7955bf8 100644 --- a/options/options.js +++ b/options/options.js @@ -255,4 +255,25 @@ version.textContent = "Version " + manifest.version; }); document.body.appendChild(version); + + settings.onloaded(function(){ + const reCaptchaEntry = "^https://www\\.google\\.com/recaptcha/api2/(?:b?frame|anchor).*$"; + const {url: urlContainer} = settings.getContainers(); + settings.on("protectWindow", function({newValue}){ + const urlValue = urlContainer.get(); + const matching = urlValue.filter(function(entry){ + return entry.url = reCaptchaEntry; + }); + if ( + newValue && + ( + matching.length === 0 || + matching[0].protectWindow + ) && + window.confirm(browser.i18n.getMessage("protectWindow_askReCaptchaException")) + ){ + settings.set("protectWindow", false, reCaptchaEntry); + } + }); + }); }());