WaniKani Fast Abridged Wrong Answer

try to take over the world!

目前為 2017-10-08 提交的版本,檢視 最新版本

// ==UserScript==
// @name         WaniKani Fast Abridged Wrong Answer
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  try to take over the world!
// @author       You
// @match        https://www.wanikani.com/review/session
// @match        https://www.wanikani.com/
// @match        https://www.wanikani.com/dashboard
// @require      https://greasyfork.org/scripts/22751-wanikani-settings/code/WaniKani%20Settings.js?version=166555
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    if(window.location.href == "https://www.wanikani.com" || window.location.href == "https://www.wanikani.com/dashboard"){
        makeSettings("Fast Wrong Answer",{1: {Name: "wkFastWrongAlwaysShow", Display: "Always Show Correct Answers", Type: "checkbox"}});
    }
    var alwaysShowCorrect = getSetting('wkFastWrongAlwaysShow');

    $('#user-response').after("<label id='lblCorrect' style='background-color: orange; display: none; height: 50px; line-height: 2em; font-size: 1.5em; font-weight: bold; color: white; text-shadow: 2px 2px 0 rgba(0,0,0,0.2) !important;'></label>");
    $('#lblCorrect').css('width',$('#user-response').css('width'));
    $.jStorage.listenKeyChange('currentItem', function (key, action) {
        if (action === 'updated') {
            $('#lblCorrect').text('').css('display','none');
        }
    });
    $.jStorage.listenKeyChange('wrongCount', function (key, action) {
        if (action === 'updated' && $.jStorage.get("wrongCount") > 0) {
            showCorrect();
        }
    });
    $.jStorage.listenKeyChange('questionCount', function (key, action) {
        if (action === 'updated' && $.jStorage.get("questionCount") > 0 && alwaysShowCorrect == "1") {
            showCorrect();
        }
    });
})();

function showCorrect(){
    $('#lblCorrect').text('').css('display','block');
    switch($('#question-type h1').text().toLowerCase()){
        case "vocabulary reading":
            $('#lblCorrect').text($.jStorage.get("currentItem").kana.join(", "));
            break;
        case "vocabulary meaning":
        case "kanji meaning":
        case "radical name":
            $('#lblCorrect').text($.jStorage.get("currentItem").en.join(", "));
            break;
        case "kanji reading":
            switch($.jStorage.get("currentItem").emph.toLowerCase()){
                case "onyomi":
                    $('#lblCorrect').text($.jStorage.get("currentItem").on.join(", "));
                    break;
                case "kunyomi":
                    $('#lblCorrect').text($.jStorage.get("currentItem").kun.join(", "));
                    break;
            }
            break;
    }
}