Greasy Fork

来自缓存

Greasy Fork is available in English.

可可英语刷单词

try to take over the world!

当前为 2019-12-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         可可英语刷单词
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Mystery
// @match        http://word.kekenet.com/*
// @grant        unsafeWindow
// ==/UserScript==

var setting = {
    random: 0//是否开启随机时间提交,默认开启,若关闭,将会立即提交
    ,minTime: 3e3//随机最小时间
    ,maxTime: 3e3//随机最大时间
},
    _self = unsafeWindow,
    url = location.pathname,
    top = _self,
    $ = _self.jQuery || top.jQuery;

(function() {
    var param = location.search,
        word = _self.word;
    if(param.match("/?do=login")){
        return;
    }else if(param.match("/?do=levelbegin")){
        //判断是否完成当前关卡
        console.log("选关页面");
        var finished = parseInt(document.getElementsByClassName("tongj").item(0).children.item(0).innerText.match(".*:([0-9]*)")[1]),
            total = parseInt(document.getElementsByClassName("tongj").item(0).children.item(1).innerText.match(".*:([0-9]*)")[1]);
        if(finished == total){
            console.log("闯关结束");
            return;
        }
        _self.go();
    }else if(param.match("/?do=round")){
        console.log("选测页面");
        _self.go('index.php?do=wordstart&type=wordexam');
    }else{
        console.log("测试页面");
        if(document.getElementsByClassName("btn4").length != 0){
            console.log("下一关");
            document.getElementsByClassName("btn4").item(0).click();
        }else{
            console.log("选择答案:" + word);
            $('input[value=' + word + ']').attr('checked',true);
            if(setting.random){
                var time = Math.floor(Math.random() * (setting.maxTime - setting.minTime) + setting.minTime);
                setTimeout(submitAnswer, time);
            }else{
                submitAnswer();
            }
        }
    }
})();

function submitAnswer(){
    $("form").submit();
}