mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +01:00
Simplified translations in inject.js
This commit is contained in:
parent
48e2966d61
commit
7ce54a25c9
Binary file not shown.
@ -6,7 +6,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
showCallingFile: false
|
showCallingFile: false,
|
||||||
|
showCompleteCallingStack: false
|
||||||
};
|
};
|
||||||
var blockMode = {
|
var blockMode = {
|
||||||
getContext: {
|
getContext: {
|
||||||
@ -247,7 +248,7 @@
|
|||||||
|
|
||||||
// Translation
|
// Translation
|
||||||
var _ = function(name, replace){
|
var _ = function(name, replace){
|
||||||
var str = _[name] || name;
|
var str = self.options.translations[name] || name;
|
||||||
if (replace){
|
if (replace){
|
||||||
Object.keys(replace).forEach(function(name){
|
Object.keys(replace).forEach(function(name){
|
||||||
str = str.replace(new RegExp("{" + name + "}", "g"), replace[name]);
|
str = str.replace(new RegExp("{" + name + "}", "g"), replace[name]);
|
||||||
@ -255,9 +256,6 @@
|
|||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
};
|
};
|
||||||
self.port.on("setTranslation", function(name, translation){
|
|
||||||
_[name] = translation;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Communication with main.js
|
// Communication with main.js
|
||||||
|
|
||||||
|
29
lib/main.js
29
lib/main.js
@ -84,11 +84,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var workers = [];
|
var workers = [];
|
||||||
|
var workerTranslations = {
|
||||||
|
sourceOutput: _("sourceOutput"),
|
||||||
|
stackEntryOutput: _("stackEntryOutput")
|
||||||
|
};
|
||||||
|
|
||||||
|
["", "Readout"].forEach(function(type){
|
||||||
|
["", "Visible", "Invisible"].forEach(function(visibility){
|
||||||
|
var text = "askFor" + visibility + type + "Permission";
|
||||||
|
workerTranslations[text] = _(text);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var workerOptions = {
|
var workerOptions = {
|
||||||
blockMode: checkURL(),
|
blockMode: checkURL(),
|
||||||
whiteList: prefs.whiteList,
|
whiteList: prefs.whiteList,
|
||||||
blackList: prefs.blackList,
|
blackList: prefs.blackList,
|
||||||
askOnce: prefs.askOnce
|
askOnce: prefs.askOnce,
|
||||||
|
translations: workerTranslations
|
||||||
};
|
};
|
||||||
preferences.on("blockMode", function(){
|
preferences.on("blockMode", function(){
|
||||||
workerOptions.blockMode = checkURL();
|
workerOptions.blockMode = checkURL();
|
||||||
@ -118,14 +131,6 @@
|
|||||||
worker.on("detach", function(){
|
worker.on("detach", function(){
|
||||||
array.remove(workers, this);
|
array.remove(workers, this);
|
||||||
});
|
});
|
||||||
["", "Readout"].forEach(function(type){
|
|
||||||
["", "Visible", "Invisible"].forEach(function(visibility){
|
|
||||||
var text = "askFor" + visibility + type + "Permission";
|
|
||||||
worker.port.emit("setTranslation", text, _(text));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
worker.port.emit("setTranslation", "sourceOutput", _("sourceOutput"));
|
|
||||||
worker.port.emit("setTranslation", "stackEntryOutput", _("stackEntryOutput"));
|
|
||||||
|
|
||||||
preferencesForInjected.forEach(function(name){
|
preferencesForInjected.forEach(function(name){
|
||||||
worker.port.emit("set", name, prefs[name]);
|
worker.port.emit("set", name, prefs[name]);
|
||||||
@ -160,6 +165,8 @@
|
|||||||
accessKey: "",
|
accessKey: "",
|
||||||
callback: function(){
|
callback: function(){
|
||||||
browser.contentWindow.alert(callingStackMsg);
|
browser.contentWindow.alert(callingStackMsg);
|
||||||
|
// only way to prevent closing... see https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/appendNotification#Notification_box_events
|
||||||
|
throw new Error("Do not close notification.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -194,14 +201,14 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
var priority = notifyBox.PRIORITY_WARNING_MEDIUM;
|
var priority = notifyBox.PRIORITY_WARNING_MEDIUM;
|
||||||
notifyBox.appendNotification(
|
notification = notifyBox.appendNotification(
|
||||||
message,
|
message,
|
||||||
"fake-readout",
|
"fake-readout",
|
||||||
"chrome://browser/skin/Info.png",
|
"chrome://browser/skin/Info.png",
|
||||||
priority,
|
priority,
|
||||||
buttons
|
buttons
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user