管理员

当剪切板内容改变时,自动翻译剪切板的内容 😒
翻译一下_20180215213750.js
https://pan.baidu.com/s/1ht7g7B2

最后由 O了吗 编辑
管理员
//当剪切板内容改变时,自动翻译剪切板的内容
toast("开始翻译剪切板内容");
while (true) {
    if (clipIsChange()) {
        word = translate(getClip());
        if (dialogs.select("翻译结果:", word) == 0) {
            setClip(word);
            toast("已复制");
        }
        else {
            setClip(getClip() + " ");
        }
    }
}

function getcenter(a, b, c) {
    a1 = a.split(b);
    b1 = [];
    for (i in a1)
        b1[i] = a1[i].split(c);
    //log(b1);
    c1 = [];
    for (var i = 0; i < b1.length; i++) {
        c1[i - 1] = b1[i][0];
    }
    return c1;
}

function clipIsChange() {
    a = getClip();
    sleep(20);
    b = getClip();
return a != b;
}
function replaceHtml(str) {
    a = [/&#39;/g, /&amp;/g, /&lt;/g, /&gt;/g];
    b = ["'", "&", "<", ">"];
    for (var i = 0; i < a.length; i++) {
        str = str.replace(a[i], b[i]);
    }
    return str;
}
function isnull(str) {
    if (str.substr(0, 24) == "<input id=\"downIt\" type=" || str.substr(0, 64) == "<span id=\"tran_0_0\" onmouseover=\"hlgt(\'#src_0_0,#tran_0_0\')\" onm") {
        return true;
    }
    else {
        return false;
    }
}

function translate(str) {
    content = str;
    word = "";
    path = "http://www.youdao.com/w/" + content + "/#keyfrom=dict2.top";
    a = http.get(path).body.string();
    bs = '<span>\n                ';
    cs = '</span>';
    d = getcenter(a, bs, cs);
    word = d[0];
    if (word == null) {
        bl = '<p>';
        cl = '</p>\n';
        dl = getcenter(a, bl, cl);
        word = dl[1];
    }
    log(word);
    if (word == null || isnull(word)) {
        word = str + " ";
    }
    word = replaceHtml(word);
    return word;
}
最后由 O了吗 编辑
管理员

@逍遥-0 复制到浏览器下载

  • 4
    帖子
  • 1929
    浏览

与 Auto.js 的连接断开,我们正在尝试重连,请耐心等待