Wanikani shaking for no reason bug fix

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

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

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

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

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

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