There's a Mozhi (fork of SimplyTranslate) instance which has DeepL as an option: https://mozhi.pussthecat.org/?engine=deepl
Updated bookmarklet code:
Code: Select all
javascript:(function translate() {
function se(d) { return d.selection ? d.selection.createRange().text : d.getSelection(); }
s = se(document);
for (i = 0; i < frames.length && !s; i++) s = se(frames[i].document);
if (!s || s == '') s = prompt('Enter text to translate with SimplyTranslate', null);
if (!s) return; /* Don't do anything if prompt cancelled */
let wn = 'w_' + Date.now() + Math.floor(Math.random() * 100000).toString();
var f = document.createElement("form");
f.setAttribute("method", "post");
f.setAttribute("action", "https://mozhi.pussthecat.org/?engine=deepl");
f.setAttribute("target", wn);
var hf = new Array(3);
for (i = 0; i < hf.length; i++) { hf[i] = document.createElement("input"); hf[i].type = "hidden"; }
hf[0].name = "from";
function avl(l) {
switch (l) {
case "bg":
case "cs":
case "da":
case "de":
case "el":
case "es":
case "et":
case "fi":
case "fr":
case "hu":
case "id":
case "it":
case "ja":
case "ko":
case "lv":
case "lt":
case "nb":
case "nl":
case "pl":
case "pt":
case "ro":
case "ru":
case "sk":
case "sl":
case "sv":
case "tr":
case "uk":
case "zh":
case "ar":
return l;
default:
return "ja";
}
}
hf[0].value = avl(document.documentElement.lang.split("-")[0]);
hf[1].name = "to";
hf[1].value = 'en';
hf[2].name = "text";
hf[2].value = s
for (i = 0; i < hf.length; i++) f.appendChild(hf[i]);
document.body.appendChild(f);
open('', wn).focus();
f.submit();
})();
Code: Select all
javascript:void%20function(){var%20a=Math.floor;function%20b(a){return%20a.selection%3Fa.selection.createRange().text:a.getSelection()}function%20c(a){return%22bg%22===a||%22cs%22===a||%22da%22===a||%22de%22===a||%22el%22===a||%22es%22===a||%22et%22===a||%22fi%22===a||%22fr%22===a||%22hu%22===a||%22id%22===a||%22it%22===a||%22ja%22===a||%22ko%22===a||%22lv%22===a||%22lt%22===a||%22nb%22===a||%22nl%22===a||%22pl%22===a||%22pt%22===a||%22ro%22===a||%22ru%22===a||%22sk%22===a||%22sl%22===a||%22sv%22===a||%22tr%22===a||%22uk%22===a||%22zh%22===a||%22ar%22===a%3Fa:%22ja%22}for(s=b(document),i=0;i%3Cframes.length%26%26!s;i++)s=b(frames[i].document);if(s%26%26%22%22!=s||(s=prompt(%22Enter%20text%20to%20translate%20with%20SimplyTranslate%22,null)),!!s){let%20b=%22w_%22+Date.now()+a(1e5*Math.random()).toString();var%20d=document.createElement(%22form%22);d.setAttribute(%22method%22,%22post%22),d.setAttribute(%22action%22,%22https://mozhi.pussthecat.org/%3Fengine=deepl%22),d.setAttribute(%22target%22,b);var%20e=[,,,];for(i=0;i%3Ce.length;i++)e[i]=document.createElement(%22input%22),e[i].type=%22hidden%22;for(e[0].name=%22from%22,e[0].value=c(document.documentElement.lang.split(%22-%22)[0]),e[1].name=%22to%22,e[1].value=%22en%22,e[2].name=%22text%22,e[2].value=s,i=0;i%3Ce.length;i++)d.appendChild(e[i]);document.body.appendChild(d),open(%22%22,b).focus(),d.submit()}}();



