Last active
September 7, 2021 09:07
-
-
Save scriptify/5897a2749ea1ba2013fccb91229e0162 to your computer and use it in GitHub Desktop.
Go to https://www.deepl.com, paste this code into your browser console, and execute "translateAll" with a key-value object as the first param.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function waitUntilValueChanges(domElem) { | |
return new Promise(resolve => { | |
let prevVal = domElem.value; | |
const inter = setInterval(() => { | |
if (domElem.value !== prevVal) { | |
clearInterval(inter); | |
return resolve(); | |
} | |
prevVal = domElem.value + ''; | |
}, 100); | |
}) | |
} | |
async function translateAll(obj) { | |
let newObj = {}; | |
for (const currKey in obj) { | |
const oldVal = obj[currKey]; | |
if (oldVal) continue; | |
$('.lmt__textarea.lmt__source_textarea.lmt__textarea_base_style')[0].value = currKey; | |
$('.lmt__textarea.lmt__source_textarea.lmt__textarea_base_style')[0].dispatchEvent(new Event('change', { value: 't' })); | |
await waitUntilValueChanges($('.lmt__textarea.lmt__target_textarea.lmt__textarea_base_style')[0]); | |
const translated = $('.lmt__textarea.lmt__target_textarea.lmt__textarea_base_style')[0].value; | |
newObj = { | |
...newObj, | |
[currKey]: translated | |
} | |
} | |
console.log(newObj); | |
return newObj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment