Update deepl translation

This commit is contained in:
Gres 2023-02-12 14:17:17 +03:00
parent 5be5def820
commit 41f1f56fe5
2 changed files with 7 additions and 5 deletions

View File

@ -41,24 +41,26 @@ function translate(text, from, to) {
active = true;
var singleLineText = text.replace(/(?:\r\n|\r|\n)/g, ' ');
let langs = from + '/' + to + '/';
if (window.location.href.indexOf('www.deepl.com/translator') !== -1
&& window.location.href.indexOf(langs) !== -1) {
var input = document.querySelector('d-textarea[dl-test=translator-source-input] p');
if (input.innerText == text) {
if (input.innerText == singleLineText) {
console.log('using cached result');
lastText = '';
return;
}
input.innerText = text;
document.querySelector('div#source-dummydiv').innerHTML = text;
input.innerText = singleLineText;
document.querySelector('div#source-dummydiv').innerHTML = singleLineText;
setTimeout(function() {
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
}, 300);
return;
}
let url = 'https://www.deepl.com/translator#' + langs + encodeURIComponent(text);
let url = 'https://www.deepl.com/translator#' + langs + encodeURIComponent(singleLineText);
console.log("setting url", url);
window.location = url;
}

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":"f9f080ae218081c49c95c9ebb136798d", "size":1966}
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"54ee1a3c198e2919abc2345acf114bac", "size":2068}
]}
,"google": {"files":[
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js", "path":"$translators$/google.js", "md5":"793d6628ac9e26a1f3cc00fa9c863495", "size":1508}