Updated bing translation
This commit is contained in:
parent
4109968fed
commit
a69213c956
@ -6,9 +6,9 @@ function checkFinished () {
|
||||
if (!isPageLoaded || !isTranslationFinished || isScheduled) return;
|
||||
isScheduled = true;
|
||||
setTimeout(function () {
|
||||
var spans = [].slice.call (document.querySelectorAll ('#destText span'));
|
||||
var spans = [].slice.call (document.querySelectorAll ('#t_txtoutblk textarea'));
|
||||
var text = spans.reduce (function (res, i) {
|
||||
return res + i.innerText;
|
||||
return res + i.value;
|
||||
}, '');
|
||||
console.log (text);
|
||||
st_wtp.translated (text);
|
||||
@ -16,15 +16,24 @@ function checkFinished () {
|
||||
}, 2000); // wait for gui fill
|
||||
}
|
||||
function onResourceLoad (url) {
|
||||
if (url.indexOf ('/translator/api/Dictionary/Lookup?') > -1) {
|
||||
if (url.indexOf ('bing.com/translator/?') > -1) {
|
||||
isTranslationFinished = true;
|
||||
checkFinished ();
|
||||
if (isPageLoaded) {
|
||||
checkFinished ();
|
||||
}
|
||||
}
|
||||
}
|
||||
st_wtp.resourceLoaded.connect (onResourceLoad);
|
||||
function onPageLoad () {
|
||||
if (window.location.href.indexOf('about:blank') === 0) {
|
||||
translate ();
|
||||
return;
|
||||
}
|
||||
|
||||
isPageLoaded = true;
|
||||
checkFinished ();
|
||||
if (isTranslationFinished) {
|
||||
checkFinished ();
|
||||
}
|
||||
}
|
||||
window.onload = onPageLoad();
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
"path_linux": "ScreenTranslator"
|
||||
},
|
||||
"Bing translator": {
|
||||
"version": 3,
|
||||
"version": 4,
|
||||
"url": "https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/bing.js",
|
||||
"path": "translators/bing.js"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user