I have installed two Firefox Extensions to translate words when I double click on them: Google Translator and Wictionary and Google Translate.
Both offer you the possibility to translate words just by double clicking on them. But the difference is, Wictionary and Google Translate just works everywhere i double click. It works with local files (file:///...) ,EPUBReader extension which opens EPUB files inside Firefox with a URL something like (about:epubreader?id=5) etc. Since I prefer Google Translator, I want to use it the same way I can use Wictionary and Google Translate, but it doesn't work with any URL other than http:// https:// .
I have tried to compare their source codes and searched several times to find and edit this functionality in Google Translator, but could not do anything.
Help anyone?? Thanks
Some directory from Google Translator
Here is the code snippet from firefox.js that is responsible for listening to the URL protocols:
var workers = [], content_script_arr = [];
pageMod.PageMod({ /* page */
include: ["*"],
contentScriptFile: [data.url("content_script/inject.js")],
contentScriptWhen: "start",
contentStyleFile : data.url("content_script/inject.css"),
onAttach: function(worker) {
array.add(workers, worker);
worker.on('pageshow', function() { array.add(workers, this); });
worker.on('pagehide', function() { array.remove(workers, this); });
worker.on('detach', function() { array.remove(workers, this); });
content_script_arr.forEach(function (arr) {
worker.port.on(arr[0], arr[1]);
});
}
});
Changing the include:
line to
include: ["*","file://*"],
will do the trick for local files.