Updated translator script.

This commit is contained in:
Gres 2017-07-21 20:24:53 +03:00
parent b11f3e9368
commit c6dc304627
2 changed files with 17 additions and 3 deletions

View File

@ -17,17 +17,31 @@ function checkFinished () {
function onResourceLoad (url) {
if (url.indexOf ('/translate_a/single') > -1) {
isTranslationFinished = true;
if (isPageLoaded) {
checkFinished ();
}
}
}
st_wtp.resourceLoaded.connect (onResourceLoad);
function onPageLoad () {
if (window.location.href.indexOf('about:blank') === 0) {
translate ();
return;
}
isPageLoaded = true;
if (isTranslationFinished) {
checkFinished ();
}
}
window.onload = onPageLoad();
function translate (){
if (window.location.href.indexOf('https://translate.google') === 0) {
window.location = 'about:blank';
return;
}
var url = 'https://translate.google.com/#auto/' +
st_wtp.resultLanguage + '/' + st_wtp.sourceText;
window.location = encodeURI (url);

View File

@ -18,7 +18,7 @@
"path": "translators/bing.js"
},
"Google translator": {
"version": 1,
"version": 2,
"url": "https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js",
"path": "translators/google.js"
},