美文网首页
针对DeepL在线翻译的格式自动整理脚本

针对DeepL在线翻译的格式自动整理脚本

作者: NewBornCyanide | 来源:发表于2020-04-23 14:09 被阅读0次

DeepL号称翻译中文比谷歌更好,在无法使用谷歌翻译时可以作为一个很好的替代。
我在一无是处的基础上,制作了加入DeepL的格式自动整理油猴脚本

(function() {
    var txt = "";
    var id = "";
    var host = window.location.host;
    var mclass="";
     if(host=="www.deepl.com")
    {
        mclass="lmt__source_textarea";
        txt = document.getElementsByClassName(mclass)[0].value;
        for (var i=0;i<txt.length;i++)
        {
            if(txt.indexOf("\n"))txt = txt.replace("\n"," ");
        }
        document.getElementsByClassName(mclass)[0].value = txt;
    }else{
        if( host == "fanyi.youdao.com" )
        {
            id = "inputOriginal";
        }
        if( host == "fanyi.baidu.com" )
        {
            id = "baidu_translate_input";
        }        
        if( host == "translate.google.cn" || host == "translate.google.com" )
        {
            id = "source";
        }
        txt = document.getElementById(id).value;
        for (i=0;i<txt.length;i++)
        {
            if(txt.indexOf("\n"))txt = txt.replace("\n"," ");
        }
        document.getElementById(id).value = txt;
    }
})();
    //setTimeout("self.location.reload();",15000);//15s

在设置中的用户匹配中加入https://www.deep.com/*以启用脚本

相关文章

网友评论

      本文标题:针对DeepL在线翻译的格式自动整理脚本

      本文链接:https://www.haomeiwen.com/subject/ynxaihtx.html