Update google translation script

Related to #37
This commit is contained in:
Gres 2020-12-06 22:40:03 +03:00
parent 6936914976
commit d46c72fafb
2 changed files with 5 additions and 4 deletions

View File

@ -4,7 +4,7 @@ var active = window.location.href !== "about:blank";
function checkFinished() {
if (!active) return;
let spans = [].slice.call(document.querySelectorAll('span.translation > span, #result_box > span'));
let spans = [].slice.call(document.querySelectorAll('span.VIiyi > span > span'));
let text = spans.reduce(function (res, i) {
return res + ' ' + i.innerText;
}, '');
@ -25,10 +25,11 @@ function translate(text, from, to) {
if (window.location.href.indexOf('//translate.google') !== -1
&& window.location.href.indexOf('&tl=' + to + '&') !== -1) {
document.querySelector('textarea#source').value = text;
document.querySelector('textarea.er8xn').value = text;
document.querySelector('textarea.er8xn').dispatchEvent(
new Event("input", { bubbles: true, cancelable: true }));
return;
}
// let url = 'https://translate.google.com/#auto/' + to + '/' + text;
let url = 'https://translate.google.com/#view=home&op=translate&sl=auto&tl=' + to + '&text=' + encodeURIComponent(text);
console.log("setting url", url);
window.location = url;

View File

@ -585,7 +585,7 @@
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"a6dfae3f63ca3fa9c7edbfaff87600e4", "size":1596}
]}
,"google": {"files":[
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js", "path":"$translators$/google.js", "md5":"16ffead93035e08e8db13279cc8b65a7", "size":1260}
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js", "path":"$translators$/google.js", "md5":"74f1064ba8f02c9c7be3821a4bdc557b", "size":1297}
]}
,"google_api": {"files":[
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google_api.js", "path":"$translators$/google_api.js", "md5":"90b9b1a5c8dc52fd4a3f28be93442a56", "size":1030}