Update deepl translation

This commit is contained in:
Gres 2023-02-06 23:40:07 +03:00
parent 12997389ff
commit 5be5def820
2 changed files with 10 additions and 7 deletions

View File

@ -4,8 +4,8 @@ var active = window.location.href !== "about:blank";
function checkFinished() {
if (!active) return;
let area = document.querySelector('textarea[dl-test=translator-target-input]');
let text = area ? area.value : '';
let area = document.querySelector('div#target-dummydiv');
let text = area ? area.innerHTML.trim() : '';
if (text === lastText || text === '')
return;
@ -44,14 +44,17 @@ function translate(text, from, to) {
let langs = from + '/' + to + '/';
if (window.location.href.indexOf('www.deepl.com/translator') !== -1
&& window.location.href.indexOf(langs) !== -1) {
var input = document.querySelector('textarea[dl-test=translator-source-input]');
if (input.value == text) {
var input = document.querySelector('d-textarea[dl-test=translator-source-input] p');
if (input.innerText == text) {
console.log('using cached result');
lastText = '';
return;
}
input.value = text;
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
input.innerText = text;
document.querySelector('div#source-dummydiv').innerHTML = text;
setTimeout(function() {
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
}, 300);
return;
}

View File

@ -594,7 +594,7 @@
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/bing.js", "path":"$translators$/bing.js", "md5":"a982e9aa6cac598f4c9bf4a56386d13e", "size":1481}
]}
,"deepl": {"files":[
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"6f1c5cd1ccd18cd663f65e6a9bf8462a", "size":1854}
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"f9f080ae218081c49c95c9ebb136798d", "size":1966}
]}
,"google": {"files":[
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js", "path":"$translators$/google.js", "md5":"793d6628ac9e26a1f3cc00fa9c863495", "size":1508}