Wanikani Multiple Answer Input

Input multiple readings/meanings

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Wanikani Multiple Answer Input
// @namespace    mempo
// @version      1.0
// @description  Input multiple readings/meanings
// @author       Mempo
// @match        https://www.wanikani.com/review/session
// @match        http://www.wanikani.com/review/session
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    console.log("/// START OF WKMAI");
    
    $('input#user-response').on('keydown',function(event){

    if (event.keyCode === 13){ 
        //event.preventDefault();
        event.stopPropagation();
        console.log("/// WKMAI: PROPAGATION: " + event.isPropagationStopped());
        
        var WKMAI;
        var wrong = false;
        
        if($.jStorage.get("questionType")==="meaning"){
            WKMAI = ["en","syn"];
        }else{
            WKMAI = ["kana","kana"];
        }
        
        $('input#user-response')[0].value.split(/[;]|[ ]{2,}/).forEach(function(element){
            if(element !== "" &&
               $.jStorage.get('currentItem')[WKMAI[0]].indexOf(capitalize(element.trim())) === -1 && 
               $.jStorage.get('currentItem')[WKMAI[1]].indexOf(capitalize(element.trim())) === -1 ){
                console.log(element + " is wrong!");
                wrong = true;
            }
        });
        if(!wrong){
            $('input#user-response')[0].value =  $('input#user-response')[0].value.split(/[;]|[ ]{2,}/)[0];
        }
        $("#answer-form form button").click();

        
        
    }
    

  });
    
  function capitalize(str){
        return str[0].toUpperCase() + str.substr(1);   
  }
  
})();