Update deepl translation
This commit is contained in:
parent
5be5def820
commit
41f1f56fe5
@ -41,24 +41,26 @@ function translate(text, from, to) {
|
|||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
|
|
||||||
|
var singleLineText = text.replace(/(?:\r\n|\r|\n)/g, ' ');
|
||||||
|
|
||||||
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[dl-test=translator-source-input] p');
|
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');
|
console.log('using cached result');
|
||||||
lastText = '';
|
lastText = '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input.innerText = text;
|
input.innerText = singleLineText;
|
||||||
document.querySelector('div#source-dummydiv').innerHTML = text;
|
document.querySelector('div#source-dummydiv').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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
console.log("setting url", url);
|
||||||
window.location = url;
|
window.location = url;
|
||||||
}
|
}
|
||||||
|
@ -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":"f9f080ae218081c49c95c9ebb136798d", "size":1966}
|
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"54ee1a3c198e2919abc2345acf114bac", "size":2068}
|
||||||
]}
|
]}
|
||||||
,"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