Update deepl translation
This commit is contained in:
parent
29ee5dda90
commit
e1ec86f298
@ -10,6 +10,10 @@ function checkFinished() {
|
|||||||
area = document.querySelector('d-textarea.lmt__target_textarea p');
|
area = document.querySelector('d-textarea.lmt__target_textarea p');
|
||||||
text = area ? area.innerText.trim() : '';
|
text = area ? area.innerText.trim() : '';
|
||||||
}
|
}
|
||||||
|
if (area == null) {
|
||||||
|
area = document.querySelector('d-textarea[data-testid=translator-target-input] p');
|
||||||
|
text = area ? area.innerText.trim() : '';
|
||||||
|
}
|
||||||
|
|
||||||
if (text === lastText || text === '')
|
if (text === lastText || text === '')
|
||||||
return;
|
return;
|
||||||
@ -24,16 +28,16 @@ function translate(text, from, to) {
|
|||||||
console.log('start translate', text, from, to)
|
console.log('start translate', text, from, to)
|
||||||
|
|
||||||
if (text.trim().length == 0) {
|
if (text.trim().length == 0) {
|
||||||
proxy.setTranslated('');
|
proxy.setTranslated('');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
from = from == 'zh-CN' ? 'zh' : from;
|
from = from == 'zh-CN' ? 'zh' : from;
|
||||||
to = to == 'zh-CN' ? 'zh' : to;
|
to = to == 'zh-CN' ? 'zh' : to;
|
||||||
|
|
||||||
let supported = ['ru', 'en', 'de', 'fr', 'es', 'pt', 'it', 'nl', 'pl', 'ja', 'zh',
|
let supported = ['ru', 'en', 'de', 'fr', 'es', 'pt', 'it', 'nl', 'pl', 'ja', 'zh',
|
||||||
'uk', 'bg', 'hu', 'el', 'da', 'id', 'lt', 'pt', 'ro', 'sk', 'sk', 'tr', 'fi', 'cs',
|
'uk', 'bg', 'hu', 'el', 'da', 'id', 'lt', 'pt', 'ro', 'sk', 'sk', 'tr', 'fi', 'cs',
|
||||||
'sv', 'et']
|
'sv', 'et']
|
||||||
if (supported.indexOf(from) == -1) {
|
if (supported.indexOf(from) == -1) {
|
||||||
proxy.setFailed('Source language not supported');
|
proxy.setFailed('Source language not supported');
|
||||||
return;
|
return;
|
||||||
@ -50,16 +54,21 @@ function translate(text, from, to) {
|
|||||||
let langs = from + '/' + to + '/';
|
let langs = from + '/' + to + '/';
|
||||||
if (window.location.href.indexOf('www.deepl.com/translator') !== -1
|
if (window.location.href.indexOf('www.deepl.com/translator') !== -1
|
||||||
&& window.location.href.indexOf(langs) !== -1) {
|
&& window.location.href.indexOf(langs) !== -1) {
|
||||||
var input = document.querySelector('d-textarea.lmt__source_textarea p');
|
|
||||||
|
var input = document.querySelector('d-textarea[dl-test=translator-source-input] p');
|
||||||
|
if (input == null)
|
||||||
|
input = document.querySelector('d-textarea.lmt__source_textarea p');
|
||||||
|
if (input == null)
|
||||||
|
input = document.querySelector('d-textarea[data-testid=translator-source-input] p');
|
||||||
if (input.innerText == singleLineText) {
|
if (input.innerText == singleLineText) {
|
||||||
console.log('using cached result');
|
console.log('using cached result');
|
||||||
lastText = '';
|
lastText = '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input.innerText = singleLineText;
|
input.innerText = singleLineText;
|
||||||
if (areaCopy = document.querySelector('div#source-dummydiv'))
|
if (areaCopy = document.querySelector('div#source-dummydiv'))
|
||||||
areaCopy.innerHTML = singleLineText;
|
areaCopy.innerHTML = singleLineText;
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
|
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
|
||||||
}, 300);
|
}, 300);
|
||||||
return;
|
return;
|
||||||
|
@ -594,7 +594,7 @@
|
|||||||
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/bing.js", "path":"$translators$/bing.js", "md5":"a982e9aa6cac598f4c9bf4a56386d13e", "size":1481}
|
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/bing.js", "path":"$translators$/bing.js", "md5":"a982e9aa6cac598f4c9bf4a56386d13e", "size":1481}
|
||||||
]}
|
]}
|
||||||
,"deepl": {"files":[
|
,"deepl": {"files":[
|
||||||
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"cda36c52ca2b60f0c237b37a44ecb2b3", "size":2231}
|
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"76856af9b80c3d0e852ca73f8f1ebbdb", "size":2611}
|
||||||
]}
|
]}
|
||||||
,"google": {"files":[
|
,"google": {"files":[
|
||||||
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js", "path":"$translators$/google.js", "md5":"793d6628ac9e26a1f3cc00fa9c863495", "size":1508}
|
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js", "path":"$translators$/google.js", "md5":"793d6628ac9e26a1f3cc00fa9c863495", "size":1508}
|
||||||
|
Loading…
Reference in New Issue
Block a user