Wanikani shaking for no reason bug fix

Fix wanikani bug where the answer box would shake even though the answer is in right format.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Wanikani shaking for no reason bug fix
// @namespace    https://www.wanikani.com
// @version      0.12
// @description  Fix wanikani bug where the answer box would shake even though the answer is in right format.
// @author       Cometzero
// @include      *://www.wanikani.com/review/session*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    $("#answer-form button").on("click", function(){
        var qt = $.jStorage.get("questionType"); // saved value in jStorage
        var htmlQt = $("#question-type h1 strong").html(); // actual value on the screen
        
        // radicals have name instead of meaning
        if(htmlQt === "Name") htmlQt = "meaning";
        
        if(qt != htmlQt) {
            console.log("Detected wrong questionType. Changing to " + htmlQt);
            $.jStorage.set("questionType", htmlQt); // set to the right value
            
            // if the shake animation is runnig we know that this click function was called
            // after the wk click function
            if($("#answer-form form").is(':animated')){
                //$("#answer-form form").finish(); // cancel the shaking animation
                $("#answer-form button").click();
            }
        }
      
    });
    
    /*
    $.jStorage.listenKeyChange('questionType', function(key, action){
        console.log(key + " has been " + action + ", new value:" + $.jStorage.get("questionType"));
        
        var qt = $.jStorage.get("questionType");
        var htmlQt = $("#question-type h1 strong").html();
        console.log(qt + " ?==? " + htmlQt);
    });
    */
})();