Wanikani Multiple Answer Input

Input multiple readings/meanings

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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);   
  }
  
})();