WaniKani Fast Abridged Wrong/Multiple Answer

try to take over the world!

目前為 2017-12-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         WaniKani Fast Abridged Wrong/Multiple Answer
// @namespace    http://tampermonkey.net/
// @version      1.1
// @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://gf.qytechs.cn/scripts/22751-wanikani-settings/code/WaniKani%20Settings.js?version=230720
// @grant        none
// ==/UserScript==

var onlyIfMultiples;
var wrongCountFAWA;
var wrongColorFAWA;
var customColorFAWA;
var multiplesColorFAWA;
(function() {
    'use strict';
// Hook into App Store
    try { $('.app-store-menu-item').remove(); $('<li class="app-store-menu-item"><a href="https://community.wanikani.com/t/there-are-so-many-user-scripts-now-that-discovering-them-is-hard/20709">App Store</a></li>').insertBefore($('.navbar .dropdown-menu .nav-header:contains("Account")')); window.appStoreRegistry = window.appStoreRegistry || {}; window.appStoreRegistry[GM_info.script.uuid] = GM_info; localStorage.appStoreRegistry = JSON.stringify(appStoreRegistry); } catch (e) {}

    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: "&nbsp;&nbsp;&nbsp;(Only if multiple answers)", Type: "checkbox"},
                    3: {Name: "wkFastWrongDontShowWrong", Display: "&nbsp;&nbsp;&nbsp;(Don't show wrongs)", Type: "checkbox"},
                    4: {Name: "wkFastWrongCustomColor", Display: "Custom Background Colors", Type: "checkbox"},
                    5: {Name: "wkFastWrongWrongColor", Display: "&nbsp;&nbsp;&nbsp;Wrongs", Type: "textbox"},
                    6: {Name: "wkFastWrongMultipleColor", Display: "&nbsp;&nbsp;&nbsp;Multiples", Type: "textbox"}});
        $('#divFastWrongAnswerLink').click(function(){
            wkFastAbridgedWrongAnswerSettingTweak();
            $('#chkwkFastWrongAlwaysShow').click(function(){
                wkFastAbridgedWrongAnswerSettingTweak();
            });
            $('#chkwkFastWrongCustomColor').click(function(){
                wkFastAbridgedWrongAnswerSettingTweak();
            });
        });
    } else {
        var alwaysShowCorrect = getSetting('wkFastWrongAlwaysShow');
        var dontShowWrong = getSetting('wkFastWrongDontShowWrong');
        onlyIfMultiples = getSetting('wkFastWrongAlwaysShowOnlyMultiple');
        customColorFAWA = getSetting('wkFastWrongCustomColor');
        wrongColorFAWA = getSetting('wkFastWrongWrongColor');
        if(wrongColorFAWA === null || wrongColorFAWA === ""){
            wrongColorFAWA = "#f03";
        }
        multiplesColorFAWA = getSetting('wkFastWrongMultipleColor');
        if(multiplesColorFAWA === null || multiplesColorFAWA === ""){
            multiplesColorFAWA = "#88cc00";
        }
        $('#user-response').after("<input id='lblCorrect' type='text' style='display: none;' disabled/>");
        $.jStorage.listenKeyChange('currentItem', function (key, action) {
            if (action === 'updated') {
                $('#lblCorrect').val('').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 != "1"){
                    showCorrect(0);
                }
            }
            else {
                if (action === 'updated' && $.jStorage.get("questionCount") > 0 && alwaysShowCorrect == "1") {
                    showCorrect(1);
                }
            }
        });
    }
})();

function showBar(mode){
    $('#lblCorrect').css('display','block');
    if(customColorFAWA === '1'){
        if(mode === 0){
            $('#lblCorrect').attr('style','display: block; background-color: ' + wrongColorFAWA + ' !important;');
        } else {
            $('#lblCorrect').attr('style','display: block; background-color: ' + multiplesColorFAWA + ' !important;');
        }
    }
}

function showCorrect(mode){
    debugger;
    switch($('#question-type h1').text().toLowerCase()){
        case "vocabulary reading":
            if(mode === 1 && onlyIfMultiples == "1" && $.jStorage.get("currentItem").kana.length === 1) return;
            showBar(mode);
            $('#lblCorrect').val($.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').val($.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').val($.jStorage.get("currentItem").on.join(", "));
                    break;
                case "kunyomi":
                    if(mode === 1 && onlyIfMultiples == "1" && $.jStorage.get("currentItem").kun.length === 1) return;
                    showBar(mode);
                    $('#lblCorrect').val($.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','');
        $('#chkwkFastWrongDontShowWrong').closest('tr').css('opacity','1.0').css('filter', 'alpha(opacity = 60)');
        $('#chkwkFastWrongDontShowWrong').prop('disabled','');
    } else {
        $('#chkwkFastWrongAlwaysShowOnlyMultiple').closest('tr').css('opacity','0.6').css('filter', 'alpha(opacity = 100)');
        $('#chkwkFastWrongAlwaysShowOnlyMultiple').prop('disabled','disabled');
        $('#chkwkFastWrongAlwaysShowOnlyMultiple').prop('checked',false);
        $('#chkwkFastWrongDontShowWrong').closest('tr').css('opacity','0.6').css('filter', 'alpha(opacity = 100)');
        $('#chkwkFastWrongDontShowWrong').prop('disabled','disabled');
        $('#chkwkFastWrongDontShowWrong').prop('checked',false);
    }
    if($('#chkwkFastWrongCustomColor').prop('checked')){
        $('#txtwkFastWrongWrongColor').closest('tr').css('opacity','1.0').css('filter', 'alpha(opacity = 100)');
        $('#txtwkFastWrongWrongColor').prop('disabled','');
        $('#txtwkFastWrongMultipleColor').closest('tr').css('opacity','1.0').css('filter', 'alpha(opacity = 100)');
        $('#txtwkFastWrongMultipleColor').prop('disabled','');
    } else {
        $('#txtwkFastWrongWrongColor').closest('tr').css('opacity','0.6').css('filter', 'alpha(opacity = 60)');
        $('#txtwkFastWrongWrongColor').prop('disabled','disabled');
        $('#txtwkFastWrongMultipleColor').closest('tr').css('opacity','0.6').css('filter', 'alpha(opacity = 60)');
        $('#txtwkFastWrongMultipleColor').prop('disabled','disabled');
        $('#txtwkFastWrongWrongColor').val('');
        $('#txtwkFastWrongMultipleColor').val('');
    }
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址