summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhackademix2019-07-25 22:15:40 +0200
committerhackademix2019-07-31 19:13:41 +0200
commit125a1a2937d77fab775647d5df6f78387bb8dc42 (patch)
tree98a4253c63ab0c4da35688fc0049d4678d4ea550
parent6ef9b4e2325a497745db058dc4a846ab31fccd27 (diff)
downloadnoscript-125a1a2937d77fab775647d5df6f78387bb8dc42.tar.gz
noscript-125a1a2937d77fab775647d5df6f78387bb8dc42.tar.xz
noscript-125a1a2937d77fab775647d5df6f78387bb8dc42.zip
Work-around for browser.i18n.getMessage() API in content scripts giving away browser's real locale (Tor issue #31287).
-rw-r--r--src/content/content.js12
-rw-r--r--src/ui/prompt.css3
2 files changed, 14 insertions, 1 deletions
diff --git a/src/content/content.js b/src/content/content.js
index dc493c2..e7fb331 100644
--- a/src/content/content.js
+++ b/src/content/content.js
@@ -1,6 +1,16 @@
'use strict';
// debug = () => {}; // REL_ONLY
-var _ = browser.i18n.getMessage;
+function _(...args) {
+ let fakeLang = navigator.language === "en-US" &&
+ browser.i18n.getUILanguage() !== "en-US";
+ return (_ = (template, ...substitutions) => {
+ let [key, defTemplate] = template.split("|");
+ return fakeLang
+ ? (defTemplate || key).replace(/\$([1-9])/g,
+ (m, p) => substitutions[parseInt(p) - 1] || "$" + p)
+ : browser.i18n.getMessage(template, ...substitutions);
+ })(...args);
+}
function createHTMLElement(name) {
return document.createElementNS("http://www.w3.org/1999/xhtml", name);
diff --git a/src/ui/prompt.css b/src/ui/prompt.css
index b85762b..abada75 100644
--- a/src/ui/prompt.css
+++ b/src/ui/prompt.css
@@ -4,6 +4,8 @@ body {
font-family: sans-serif;
font-size: 12px;
color: #222;
+ margin: 0px;
+ padding: 8px;
}
#header {
@@ -84,6 +86,7 @@ body {
.choices label {
display: block;
padding-bottom: .5em;
+ word-break: break-all;
}
#buttons {