// ==UserScript== // @name 扇贝单词拼写检查 // @namespace liyutze.seikiri@gmail.com // @version 1.0.1 // @description Quick Review Words by Respelling // @author Li Yutze // @include https://www.shanbay.com/bdc/review/ // @run-at document-end // @grant none // @downloadURL https://update.greasyfork.icu/scripts/34450/%E6%89%87%E8%B4%9D%E5%8D%95%E8%AF%8D%E6%8B%BC%E5%86%99%E6%A3%80%E6%9F%A5.user.js // @updateURL https://update.greasyfork.icu/scripts/34450/%E6%89%87%E8%B4%9D%E5%8D%95%E8%AF%8D%E6%8B%BC%E5%86%99%E6%A3%80%E6%9F%A5.meta.js // ==/UserScript== list_of_test = []; enter_cont = 1; $("body").prepend([ '
', '
', '
', '', '', '', '', '', '
', '
', '', '', '', '', '
', '

', '', '
', '', '', '', '
', '

', '
', '', '', '词后着重', '词后提示', '
', '
'].join("")); function updateWordList() { len = list_of_test.length; blk = len - $("#test-list-b").val(); red = blk - $("#test-list-r").val(); $("#test-listed").children().remove(); for (i = 0; i < list_of_test.length; i++) { col = "#999"; if (i < red) { col = "#d50"; } else if (i < blk) { col = "#000"; } $("#test-listed").prepend('

' + list_of_test[i][1] + "

"); } } function tellAnswer(what) { if (what == "correct") { $("#test-tell-c").show(); $("#test-tell-c").fadeOut("slow"); } else { $("#test-tell-r").show(); $("#test-tell-r").fadeOut("slow"); } } function tellAdd(what) { if (what == "ok") { $("#test-tell-o").show(); $("#test-tell-o").fadeOut("slow"); } else { $("#test-tell-p").show(); $("#test-tell-p").fadeOut("slow"); } } $("#test-add").click(function() { if ($("h1.content").length) { wo = $("h1.content").clone().children().remove().end().text().trim(); an = $("#review-definitions span.text").text().trim().replace("\n", " | "); hi = $("#test-h").val(); list_of_test.push([wo, an, hi, 1]); tellAdd("ok"); updateWordList(); } else { tellAdd("problem"); } $("#test-h").val(""); }); $(document).keyup(function(e){ if (e.which == 192) { $("#test-add").click(); } else if (e.which == 27) { if ($("#test-a").is(":focus")) { $("#test-a").blur(); } else { $("#test-a").focus(); } } }); $("#test-check").click(function() { if ($("#test-a").val() == list_of_test[0][0]) { tellAnswer("correct"); enter_cont = 0; } else { tellAnswer("wrong"); } }); $("#test-a").keyup(function(e){ if (e.which == 13) { if (enter_cont == 1) { $("#test-check").click(); } else { $("#test-next").click(); } } else if (e.which == 39) { $("#test-hint").click(); } else if (e.which == 38) { $("#test-top").click(); } }); $("#test-hint").click(function() { if (list_of_test[0][2] == "") { $("#test-a").val(list_of_test[0][0].substring(0, list_of_test[0][3])); list_of_test[0][3]++; } else { $("#test-listed").append('

' + list_of_test[0][2] + "

"); list_of_test[0][2] = ""; } }); $("#test-top").click(function() { list_of_test[0][3] = 1; list_of_test.push(list_of_test[0]); list_of_test.shift(); updateWordList(); $("#test-a").val(""); enter_cont = 1; }); $("#test-next").click(function() { list_of_test.shift(); updateWordList(); $("#test-a").val(""); enter_cont = 1; }); $("#search-wi").click(function() { what = $("h1.content").clone().children().remove().end().text().trim().replace(" ", "+"); window.open("http://wordinfo.info/results?searchString=" + what, "_blank"); }); $("#search-et").click(function() { what = $("h1.content").clone().children().remove().end().text().trim().replace(" ", "+"); window.open("http://www.etymonline.com/search?q=" + what, "_blank"); });