Js use batch translation of words, hence the saying batch translation.

Youdao translation provided translation api can get the words, but the results contain only a meaning in Chinese, some words have multiple meanings are multiple parts of speech, so I want to get all the way to translate a word. Not write reptiles, so I used js programming, access to translation results all the words in the array.
Usage:
1, Firefox refueling Monkey
2 updated wordBank vocabulary
3, click on the appropriate button in the proper way page
4, refresh the page.
5, after the translation, copy the table to the last page surface.

// ==UserScript==
// @name 有道提取翻译结果
// @namespace Violentmonkey Scripts
// @match http://youdao.com/*
// @match http://www.youdao.com/*
// @grant none
// ==/UserScript==
// 

var wordBank = new Array;
wordBank = ["explanation", "receiving", "bother", "entire", "entrance", "attack", "Seriously", "boots", "annual",
    "Centipede", "planned", "crocodile", "village", "exam", "Prediction", "Mirror", "obsessed", "appearance", "kept", "escaped", "gasped",
    "tunnel", "crawl", "shopkeeper", "melt", "vet", "giggled", "folk", "penny", "spill", "unfair", "lamb", "screamed", "continued",
    "weaknesses", "searched", "strengths", "plug", "elevator", "mosquito", "ton", "stunned", "quiz",
    "pressed", "purifier", "Changer", "wrinkle", "useless", "failed", "palace", "Majesty", "kilometer", "agreed", "thumb", "royal", "craftsman",
    "delighted", "normal", "upside", "knowledge", "priceless", "cents", "rum", "cider", "whisky", "alcohol", "cocktail", "wine", "recently", "track",
    "pleasant", "success", "half", "gleaming", "corner", "costume", "held", "wander", "spot", "waiter", "general", "fled", "flee", "probably", "threat",
    "approach", "split", "nimble", "alley", "chased", "America", "shield", "flavor", "legendary", "potion", "tastier", "hedgehog", "squirrel",
];

var table01 = $(
    '<table id="table01" border="1" cellspacing="0"><tr><td class="num">单词</td><td class="timu">翻译</td></tr></table>'
);

$(document).ready(function () {

    $("body").append(table01);
    for (var i in wordBank) {
        if ($(".keyword").html().toUpperCase() == wordBank[i].toUpperCase()) {
            if (localStorage.getItem('T_' + wordBank[i]) == 'undefine') {
                localStorage.setItem('T_' + wordBank[i], $(".trans-container").html())
                break;
            }
        }
    }
    for (var i in wordBank) {
        if (localStorage.getItem('T_' + wordBank[i]) == 'undefine') {
            //跳转待翻译的单词
            window.location.href = "http://www.youdao.com/w/eng/" + wordBank[i];
        }
    }
    for (var i in wordBank) {

        var arrRow = [];
        arrRow.push('<tr><td>');
        arrRow.push(wordBank[i]);
        arrRow.push('</td><td>');
        arrRow.push(localStorage.getItem('T_' + wordBank[i]));
        arrRow.push('</td></tr>');

        $('#table01').append(arrRow.join(''));

    }

});


var btn05 = $("<input type='button' id='wzmBtn'  value='先点击此按钮,然后刷新网页'   style='height:100px;font-size: 24px;'>");
$("body").append(btn05);
$("div.result_navigator").after(btn05);
document.getElementById("wzmBtn").addEventListener("click", function () {

    showtext();
});
var btn06 = $("<input type='button' id='clrBtn'  value='清除结果'   style='height:100px;font-size: 24px;'>");
$("body").append(btn06);
$("div.result_navigator").after(btn06);
document.getElementById("clrBtn").addEventListener("click", function () {

    clearBtn();
});
function clearBtn(){
   localStorage.clear();
}


function showtext() {
    console.log($(".keyword").html());
    console.log($(".trans-container").html());
    for (var i in wordBank) {
        localStorage.setItem('T_' + wordBank[i], 'undefine');
    }

}
Published 14 original articles · won praise 1 · views 6688

Guess you like

Origin blog.csdn.net/weixin_43833645/article/details/100938144