WaniKani Fast Abridged Wrong Answer

try to take over the world!

当前为 2017-11-05 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         WaniKani Fast Abridged Wrong Answer
// @namespace    http://tampermonkey.net/
// @version      0.6
// @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==

var onlyIfMultiples;
var wrongCountFAWA;
(function() {
    'use strict';
    wrongCountFAWA = $.jStorage.get("wrongCount");
    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"},
                    2: {Name: "wkFastWrongAlwaysShowOnlyMultiple", Display: "  (Only if multiple answers)", Type: "checkbox"},
                    3: {Name: "wkFastWrongDontShowWrong", Display: "Don't show on wrong (just show multiples on corrects)", Type: "checkbox"}});
        $('#divFastWrongAnswerLink').click(function(){
            wkFastAbridgedWrongAnswerSettingTweak();
            $('#chkwkFastWrongAlwaysShow').click(function(){
                wkFastAbridgedWrongAnswerSettingTweak();
            });
        });
    }
    var alwaysShowCorrect = getSetting('wkFastWrongAlwaysShow');
    var dontShowWrong = getSetting('wkFastWrongDontShowWrong');
    onlyIfMultiples = getSetting('wkFastWrongAlwaysShowOnlyMultiple');
    $('#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(0);
    //    }
    //});
    $.jStorage.listenKeyChange('questionCount', function (key, action) {
        if(wrongCountFAWA != $.jStorage.get("wrongCount"))
        {
            wrongCountFAWA = $.jStorage.get("wrongCount");
            if(dontShowWrong == "0"){
                showCorrect(0);
            }
        }
        else {
            if (action === 'updated' && $.jStorage.get("questionCount") > 0 && alwaysShowCorrect == "1") {
                showCorrect(1);
            }
        }
    });
})();

function showBar(mode){
    $('#lblCorrect').text('').css('display','block');
    $('#lblCorrect').text('').css('background-color', mode === 0 ? 'orange' : 'blue');
}

function showCorrect(mode){
    switch($('#question-type h1').text().toLowerCase()){
        case "vocabulary reading":
            if(mode === 1 && onlyIfMultiples == "1" && $.jStorage.get("currentItem").kana.length === 1) return;
            showBar(mode);
            $('#lblCorrect').text($.jStorage.get("currentItem").kana.join(", "));
            break;
        case "vocabulary meaning":
        case "kanji meaning":
        case "radical name":
            if(mode === 1 && onlyIfMultiples == "1" && $.jStorage.get("currentItem").en.length === 1) return;
            showBar(mode);
            $('#lblCorrect').text($.jStorage.get("currentItem").en.join(", "));
            break;
        case "kanji reading":
            switch($.jStorage.get("currentItem").emph.toLowerCase()){
                case "onyomi":
                    if(mode === 1 && onlyIfMultiples == "1" && $.jStorage.get("currentItem").on.length === 1) return;
                    showBar(mode);
                    $('#lblCorrect').text($.jStorage.get("currentItem").on.join(", "));
                    break;
                case "kunyomi":
                    if(mode === 1 && onlyIfMultiples == "1" && $.jStorage.get("currentItem").kun.length === 1) return;
                    showBar(mode);
                    $('#lblCorrect').text($.jStorage.get("currentItem").kun.join(", "));
                    break;
            }
            break;
    }
}

function wkFastAbridgedWrongAnswerSettingTweak(){
    if($('#chkwkFastWrongAlwaysShow').prop('checked')){
        $('#chkwkFastWrongAlwaysShowOnlyMultiple').closest('tr').css('opacity','1.0').css('filter', 'alpha(opacity = 60)');
        $('#chkwkFastWrongAlwaysShowOnlyMultiple').prop('disabled','');
    } else {
        $('#chkwkFastWrongAlwaysShowOnlyMultiple').closest('tr').css('opacity','0.6').css('filter', 'alpha(opacity = 100)');
        $('#chkwkFastWrongAlwaysShowOnlyMultiple').prop('disabled','disabled');
        $('#chkwkFastWrongAlwaysShowOnlyMultiple').prop('checked',false);
    }
}