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";
|
||||
|
||||
var settings = {
|
||||
showCallingFile: false
|
||||
showCallingFile: false,
|
||||
showCompleteCallingStack: false
|
||||
};
|
||||
var blockMode = {
|
||||
getContext: {
|
||||
@ -247,7 +248,7 @@
|
||||
|
||||
// Translation
|
||||
var _ = function(name, replace){
|
||||
var str = _[name] || name;
|
||||
var str = self.options.translations[name] || name;
|
||||
if (replace){
|
||||
Object.keys(replace).forEach(function(name){
|
||||
str = str.replace(new RegExp("{" + name + "}", "g"), replace[name]);
|
||||
@ -255,9 +256,6 @@
|
||||
}
|
||||
return str;
|
||||
};
|
||||
self.port.on("setTranslation", function(name, translation){
|
||||
_[name] = translation;
|
||||
});
|
||||
|
||||
// Communication with main.js
|
||||
|
||||
|
29
lib/main.js
29
lib/main.js
@ -84,11 +84,24 @@
|
||||
}
|
||||
|
||||
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 = {
|
||||
blockMode: checkURL(),
|
||||
whiteList: prefs.whiteList,
|
||||
blackList: prefs.blackList,
|
||||
askOnce: prefs.askOnce
|
||||
askOnce: prefs.askOnce,
|
||||
translations: workerTranslations
|
||||
};
|
||||
preferences.on("blockMode", function(){
|
||||
workerOptions.blockMode = checkURL();
|
||||
@ -118,14 +131,6 @@
|
||||
worker.on("detach", function(){
|
||||
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){
|
||||
worker.port.emit("set", name, prefs[name]);
|
||||
@ -160,6 +165,8 @@
|
||||
accessKey: "",
|
||||
callback: function(){
|
||||
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;
|
||||
notifyBox.appendNotification(
|
||||
notification = notifyBox.appendNotification(
|
||||
message,
|
||||
"fake-readout",
|
||||
"chrome://browser/skin/Info.png",
|
||||
priority,
|
||||
buttons
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user