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() { function checkFinished() {
if (!active) return; if (!active) return;
let area = document.querySelector('textarea[dl-test=translator-target-input]'); let area = document.querySelector('div#target-dummydiv');
let text = area ? area.value : ''; let text = area ? area.innerHTML.trim() : '';
if (text === lastText || text === '') if (text === lastText || text === '')
return; return;
@ -44,14 +44,17 @@ 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('textarea[dl-test=translator-source-input]'); var input = document.querySelector('d-textarea[dl-test=translator-source-input] p');
if (input.value == text) { if (input.innerText == text) {
console.log('using cached result'); console.log('using cached result');
lastText = ''; lastText = '';
return; return;
} }
input.value = text; input.innerText = text;
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true })); document.querySelector('div#source-dummydiv').innerHTML = text;
setTimeout(function() {
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
}, 300);
return; 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} {"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":"6f1c5cd1ccd18cd663f65e6a9bf8462a", "size":1854} {"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"f9f080ae218081c49c95c9ebb136798d", "size":1966}
]} ]}
,"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}