Wanikani shaking for no reason

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Wanikani shaking for no reason
// @namespace    https://www.wanikani.com
// @version      0.03
// @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(e){
        var qt = $.jStorage.get("questionType"); // saved value in jStorage
        var htmlQt = $("#question-type h1 strong").html(); // actual value on the screen
        
        if(qt != htmlQt) {
            console.log("Detected wrong questionType. Changing to " + htmlQt);
            $.jStorage.set("questionType", htmlQt); // set to the right value
            
            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);
    });
    */
})();