WaniKani Fast Abridged Wrong Answer

try to take over the world!

目前為 2017-11-05 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
    }
}