[Userscript] auto-commit; the end of the enter key

I got tired of refreshing the page every time I wanted to do reviews to get this script working, so I made a version that works without refreshing. I will leave it here in case anyone else also wants to use it.
I could not post the whole thing, because the @ symbols in the header were registering as mentions, and you can apparently only mention up to 10 people in a post. I don’t think the missing part of the header is important, but otherwise you can take that from the old verion.

Updated script

`// ==UserScript==
// @name WK Auto Commit
// @namespace WKAUTOCOMMIT
// @version 0.4.9
// @description Auto commit for Wanikani
// @author Johannes Mikulasch
// @match https://www.wanikani.com/*
// @match http://www.wanikani.com/subject-lessons/*
// @match https://www.wanikani.com/subject-lessons/*
// REST OF OLD HEADER HERE
// ==/UserScript==

/*

  • WK Auto Commit
  • If you typed in the correct answer then it is automatically commited.
  • Therefore, you have to use the ‘enter’ key way less than before.
  • Version 0.4.9
  • Fix: Support for turbo pages.
  • Version 0.4.8
  • Fix: Run this script on “wanikani.com/subject-lessons”, as Wanikani have just renamed their lessons URL
  • Version 0.4.7
  • Fix: show button to activate/deactivate in footer again.
  • Version 0.4.6
  • Revert input detection to onkeyup, as “input” event missed kana input
  • Version 0.4.5
  • Consider user-defined synonyms for the meaning of a vocab/kanji/radical as well
  • Further prevent double commits by using the “input” element’s “input” event instead of the “onkeyup” function
  • Version 0.4.4
  • Bugfix: correctly detect double-check from lightning mode
  • Version 0.4.3
  • Bugfix: prevent a double commit when typing fast, which led to a shaking input window or in the worst case to
  • wrong input.
  • Version 0.4.2
  • Quickfix: adapt to Wanikani update, which was deployed on March 27th, 2023
  • (see Updates to Lessons, Reviews, and Extra Study)
    • removed jStorage and jQuery references
    • changed the @match for the new lesson and review urls
    • Note: did not check with compatibilites of other user scripts (like Lightning mode or Katakana for On’yomi) yet.
  • Version 0.4.1
  • Bugfix: call commit() at most one time for each item
  • (see [Userscript] auto-commit; the end of the enter key - #64 by wanikanier)
  • Version 0.4
  • Compatibility with Lightning mode from the Double-Check userscript
  • Compatibility with Katakana For On’yomi userscript
  • Version 0.3
  • Script works now on the Lessons page too
  • Version 0.2
  • Makes script work with Greasemonkey and Firefox
  • Version 0.1
  • Initial version

*/

/* jshint -W097 */
‘use strict’;

let script_name = ‘WK Auto Commit’;
let wkof_version_needed = ‘1.2.3’;

if (!window.wkof) {
if (confirm(script_name+’ requires Wanikani Open Framework.\nDo you want to be forwarded to the installation instructions?‘)) {
window.location.href = ‘Installing Wanikani Open Framework’;
}
return;
}
if (wkof.version.compare_to(wkof_version_needed) === ‘older’) {
if (confirm(script_name+’ requires Wanikani Open Framework version ‘+wkof_version_needed+’.\nDo you want to be forwarded to the update page?')) {
window.location.href = ‘Wanikani Open Framework’;
}
return;
}

wkof.on_pageload([
‘/subjects/extra_study’,
‘/subjects/review’,
‘/subject-lessons/*’
], () => setTimeout(load_script, 0));

var activated = true;
var click_threshold = 600;

let expected_answers = ;
let synonyms = {};

var is_userscript_lightningmode_active = function () {
/* Returns true if “Lightning Mode” from Userscript Double-Check is active */
return Boolean(document.querySelector(‘.doublecheck-active’));
};

var toggle = function () {
var button = document.querySelector(“#WKAUTOCOMMIT_button”);
if (activated) {
// Deactivates WK Auto Commit mode
button.title = “Switch auto commit on”;
button.style.opacity = 0.5;
button.textContent = “Auto Commit is off”;
activated = false;
} else {
// Activates WK Auto Commit mode
button.title = “Switch auto commit off”;
button.style.opacity = 1.0;
button.textContent = “Auto Commit is on”;
activated = true;
}
};

var sanitize = function (str1) {
var str2 = str1.replace(/\s/g, ‘’); // Removes Whitespaces
str2 = str2.toLowerCase();
return str2;
};

var commit = function () {
if(!commit.usable) return;
// Temporarily deactivate the commit function to prevent double commits
commit.usable = false;
const inputbutton = document.querySelector(“.quiz-input__submit-button”);
inputbutton.click();
if (!is_userscript_lightningmode_active()) {
setTimeout(function(){ inputbutton.click();}, click_threshold);
}

};

var check_input = function () {
const currentresponse = document.querySelector(“#user-response”).value;
//console.log(“Checking Input”, currentresponse, expected_answers);
for (var i in expected_answers) {
if (sanitize(currentresponse) === sanitize(expected_answers[i])) {
commit();
break;
}
}
};

var register_check_input = function () {
var userinput = document.querySelector(“#user-response”);
//userinput.addEventListener(“input”, function (event) {
userinput.onkeyup = function (event) {
if (activated) {
check_input();
}
};
};

var addButton = function () {
/* Define button */
var button = document.querySelector(“#WKAUTOCOMMIT_button”);
if (!button) {
button = document.createElement(“div”);
button.id = “WKAUTOCOMMIT_button”;
button.title = “Toggle Auto Commit Mode”;
button.textContent = “Auto Commit is on”;
button.style.backgroundColor = “#C55”;
button.style.opacity = 1;
button.style.display = “inline-block”;
button.style.fontSize = “0.8125em”;
button.style.color = “#FFF”;
button.style.cursor = “pointer”
button.style.padding = “10px”;
button.style.marginLeft = “10px”;
button.style.verticalAlign = “bottom”;
button.onclick = toggle;

    /* Prepend button to footer */
    var footer = document.querySelector(".quiz-footer");
    footer.appendChild(button);
}

};

/* Load user synonyms. Load them only once. */
var loadSynonyms = function () {
if (loadSynonyms.loaded) return;
const dataUserSynonyms = document.querySelector(‘script[data-quiz-user-synonyms-target]’);
if (!dataUserSynonyms) return;
synonyms = JSON.parse(dataUserSynonyms.innerHTML);
loadSynonyms.loaded = true;
};

function load_script(){
/* Save synonyms added by the user during the quiz session */
window.addEventListener(“didUpdateUserSynonyms”, function(event) {
//console.log(“Received didUpdateUserSynonyms event from WaniKani”, event);
synonyms[event.detail.subjectId] = event.detail.synonyms;
});

/* React on a willShowNextQuestion event, which is triggered by WaniKani when a new question is shown */
window.addEventListener("willShowNextQuestion", function(event) {
    //console.log("Received willShowNextQuestion event from WaniKani", event);
    register_check_input();
    addButton();
    loadSynonyms();

    /* Get expected answers from current item depending on the task (reading or meaning) */
    expected_answers = []
    const item = event.detail;
    const subject = item.subject;
    if (item.questionType === "meaning") {
        expected_answers = expected_answers.concat(subject.meanings);
        const subjectSynonyms = (subject.id in synonyms) ? synonyms[subject.id] : [];
        expected_answers = expected_answers.concat(subjectSynonyms);
    } else if (item.questionType === "reading") {
        if (subject.type === 'Vocabulary') {
            expected_answers = expected_answers.concat(subject.readings.map((e) => e.reading));
        } else if (subject.type === 'Kanji') {
            if (subject.primary_reading_type === 'kunyomi') {
                expected_answers = expected_answers.concat(subject.kunyomi);
            } else if (subject.primary_reading_type === 'onyomi') {
                expected_answers = expected_answers.concat(subject.onyomi);
            }
        }
    }

    // Make the commit function usable again
    commit.usable = true;
});
console.log('WK Auto Commit (a plugin for Wanikani): Initialized');

}

`

Edit: Huh. Looks like the usernames ‘namespace’ and ‘match’ are actually in use. I wonder if posting a codefragment like this also sends notifications?

1 Like

Thank you for bringing attention to this behavior again and your work on fixing this!

I wasn’t aware that the script only runs when the review page is refreshed. Apparently that’s because of a Wanikani change in July 2024, which is already discussed in this forum thread: Detecting page change in userscripts

I see that your fix uses the Wanikani Open Framework ‘wkof’. I wanted to avoid the dependency on other user scripts, to keep the script easy to install and its footprint small. I think there is a way to directly react on one of the Turbo frameworks events. I will check the next days if this is possible and update the script accordingly. Your fix already points me to the right direction - thank you for that!

Also, as I am not very active on Wanikani anymore, if you or someone else wants to help maintaining this user script, you can reach out to me or directly send me a Pull Request via the user script’s github repository.

I think you need to make sure that you use the “Preformatted text” markdown in your response, the one with three backticks ``` at the start and end, like this:

```
code comes here
```
1 Like

The base solution is to add a listener for the turbo:load event, but that might have already fired before the script starts executing. Using Wkof was the quick and easy fix because it already handled that and other possible turbo details I don’t know about, and it has the same regex syntax as the regular @match statements that it replaces, but you could of course just reimplement the relevant parts directly as well.

Thank you for the fix! Auto Commit really needs to be a standard feature in WK.

1 Like

It’s broken for me, as of this afternoon. “Auto Commit is on” message still shows up, but it doesn’t fire. Any ideas? I wasn’t aware of any new updates. Also in the unfortunate boat of “I can’t really use the site without this”.

1 Like

seems like everytime wk updates their server it breaks userscripts; my scripts / workflow is totally busted following the maintenance.

1 Like

Quite the pain. Do you know if there’s any chance of this script getting updated/fixed? I don’t understand why this isn’t a feature already, hitting the enter key 400 times a day for 200 reviews is painful.

Try de-installing all scripts then reinstalling

It’s the only script I’ve used. Have tried to reinstall several times.

Try this. Not sure if it fixes every issue but it’s worked for me for ~90 reviews. I only changed the willShowNextQuestion event listener

// ==UserScript==
// @name         WK Auto Commit
// @namespace    WKAUTOCOMMIT
// @version      0.4.8
// @description  Auto commit for Wanikani
// @author       Johannes Mikulasch
// @match        http://www.wanikani.com/subjects/*
// @match        https://www.wanikani.com/subjects/*
// @match        http://www.wanikani.com/subject-lessons/*
// @match        https://www.wanikani.com/subject-lessons/*
// @grant        none
// @run-at       document-end
// @license
// @downloadURL https://update.greasyfork.org/scripts/16466/WK%20Auto%20Commit.user.js
// @updateURL https://update.greasyfork.org/scripts/16466/WK%20Auto%20Commit.meta.js
// ==/UserScript==

/*
 * WK Auto Commit
 * If you typed in the correct answer then it is automatically commited.
 * Therefore, you have to use the 'enter' key way less than before.
 *
 * Version 0.4.8
 *  Fix: Run this script on "wanikani.com/subject-lessons", as Wanikani have just renamed their lessons URL
 * Version 0.4.7
 *  Fix: show button to activate/deactivate in footer again.
 * Version 0.4.6
 *  Revert input detection to onkeyup, as "input" event missed kana input
 * Version 0.4.5
 *  Consider user-defined synonyms for the meaning of a vocab/kanji/radical as well
 *  Further prevent double commits by using the "input" element's "input" event instead of the "onkeyup" function
 * Version 0.4.4
 *  Bugfix: correctly detect double-check from lightning mode
 * Version 0.4.3
 *  Bugfix: prevent a double commit when typing fast, which led to a shaking input window or in the worst case to
 *   wrong input.
 * Version 0.4.2
 *  Quickfix: adapt to Wanikani update, which was deployed on March 27th, 2023
 *   (see https://community.wanikani.com/t/updates-to-lessons-reviews-and-extra-study/60912)
 *   - removed jStorage and jQuery references
 *   - changed the @match for the new lesson and review urls
 *   - Note: did not check with compatibilites of other user scripts (like Lightning mode or Katakana for On'yomi) yet.
 * Version 0.4.1
 *  Bugfix: call commit() at most one time for each item
 *   (see https://community.wanikani.com/t/userscript-auto-commit-the-end-of-the-enter-key/11825/64)
 * Version 0.4
 *  Compatibility with Lightning mode from the Double-Check userscript
 *  Compatibility with Katakana For On'yomi userscript
 * Version 0.3
 *  Script works now on the Lessons page too
 * Version 0.2
 *  Makes script work with Greasemonkey and Firefox
 * Version 0.1
 *  Initial version
 *
 */

/* jshint -W097 */
'use strict';

var activated = true;
var click_threshold = 600;

let expected_answers = [];
let synonyms = {};

var is_userscript_lightningmode_active = function () {
    /* Returns true if "Lightning Mode" from Userscript Double-Check is active */
    return Boolean(document.querySelector('.doublecheck-active'));
};

var toggle = function () {
    var button = document.querySelector("#WKAUTOCOMMIT_button");
    if (activated) {
        // Deactivates WK Auto Commit mode
        button.title = "Switch auto commit on";
        button.style.opacity = 0.5;
        button.textContent = "Auto Commit is off";
        activated = false;
    } else {
        // Activates WK Auto Commit mode
        button.title = "Switch auto commit off";
        button.style.opacity = 1.0;
        button.textContent = "Auto Commit is on";
        activated = true;
    }
};

var sanitize = function (str1) {
    var str2 = str1.replace(/\s/g, ''); // Removes Whitespaces
    str2 = str2.toLowerCase();
    return str2;
};

var commit = function () {
    if(!commit.usable) return;
    // Temporarily deactivate the commit function to prevent double commits
    commit.usable = false;
    const inputbutton = document.querySelector(".quiz-input__submit-button");
    inputbutton.click();
    if (!is_userscript_lightningmode_active()) {
        setTimeout(function(){ inputbutton.click();}, click_threshold);
    }

};

var check_input = function () {
        const currentresponse = document.querySelector("#user-response").value;
        //console.log("Checking Input", currentresponse, expected_answers);
        for (var i in expected_answers) {
            if (sanitize(currentresponse) === sanitize(expected_answers[i])) {
                commit();
                break;
            }
        }
};

var register_check_input = function () {
    var userinput = document.querySelector("#user-response");
    //userinput.addEventListener("input", function (event) {
    userinput.onkeyup = function (event) {
        if (activated) {
            check_input();
        }
    };
};

var addButton = function () {
    /* Define button */
    var button = document.querySelector("#WKAUTOCOMMIT_button");
    if (!button) {
        button = document.createElement("div");
        button.id = "WKAUTOCOMMIT_button";
        button.title = "Toggle Auto Commit Mode";
        button.textContent = "Auto Commit is on";
        button.style.backgroundColor = "#C55";
        button.style.opacity = 1;
        button.style.display = "inline-block";
        button.style.fontSize = "0.8125em";
        button.style.color = "#FFF";
        button.style.cursor = "pointer"
        button.style.padding = "10px";
        button.style.marginLeft = "10px";
        button.style.verticalAlign = "bottom";
        button.onclick = toggle;

        /* Prepend button to footer */
        var footer = document.querySelector(".quiz-footer");
        footer.appendChild(button);
    }
};

/* Load user synonyms. Load them only once. */
var loadSynonyms = function () {
    if (loadSynonyms.loaded) return;
    const dataUserSynonyms = document.querySelector('script[data-quiz-user-synonyms-target]');
    if (!dataUserSynonyms) return;
    synonyms = JSON.parse(dataUserSynonyms.innerHTML);
    loadSynonyms.loaded = true;
};

/* Save synonyms added by the user during the quiz session */
window.addEventListener("didUpdateUserSynonyms", function(event) {
    //console.log("Received didUpdateUserSynonyms event from WaniKani", event);
    synonyms[event.detail.subjectId] = event.detail.synonyms;
});

/* React on a willShowNextQuestion event, which is triggered by WaniKani when a new question is shown */
window.addEventListener("willShowNextQuestion", function(event) {
    //console.log("Received willShowNextQuestion event from WaniKani", event);
    register_check_input();
    addButton();
    loadSynonyms();

    /* Get expected answers from current item depending on the task (reading or meaning) */
    expected_answers = []
    const item = event.detail;
    const subject = item.subject;
    if (item.questionType === "meaning") {
        const acceptedKind = [ "alternative", "primary", "allowed" ];
        expected_answers = expected_answers.concat(subject.meanings.filter((e) => acceptedKind.includes(e.kind)).map((e) => e.text));
        const subjectSynonyms = (subject.id in synonyms) ? synonyms[subject.id] : [];
        expected_answers = expected_answers.concat(subjectSynonyms);
    } else if (item.questionType === "reading") {
        if (subject.type === 'Vocabulary') {
            expected_answers = expected_answers.concat(subject.readings.map((e) => e.text));
        } else if (subject.type === 'Kanji') {
            expected_answers = expected_answers.concat(subject.readings.filter((e) => subject.primary_reading_type === e.type).map((e) => e.text));
        }
    }

    // Make the commit function usable again
    commit.usable = true;
});

(function () {
    console.log('WK Auto Commit (a plugin for Wanikani): Initialized');
})();
6 Likes

Not that poster, but I was having the same problem and copy pasting that into the edit box made it work again, thanks! (I get that that’s exactly what you’re supposed to do with it, but I’ve never tampered with the code before and it’s nice to see it just work after the most obvious method!!)

thank you so much.
i can’t live without auto-commit anymore

1 Like

I found a situation where it submits when your answer is wrong on what I originally posted so here’s one that should fix that. I also changed it to load the script on the main page and that seems to have fixed the issue of needing to refresh the page to get the script to load on my setup at least.

// ==UserScript==
// @name         WK Auto Commit
// @namespace    WKAUTOCOMMIT
// @version      0.4.8
// @description  Auto commit for Wanikani
// @author       Johannes Mikulasch
// @match        http://www.wanikani.com/*
// @match        https://www.wanikani.com/*
// @license
// @downloadURL https://update.greasyfork.org/scripts/16466/WK%20Auto%20Commit.user.js
// @updateURL https://update.greasyfork.org/scripts/16466/WK%20Auto%20Commit.meta.js
// ==/UserScript==

/*
 * WK Auto Commit
 * If you typed in the correct answer then it is automatically commited.
 * Therefore, you have to use the 'enter' key way less than before.
 *
 * Version 0.4.8
 *  Fix: Run this script on "wanikani.com/subject-lessons", as Wanikani have just renamed their lessons URL
 * Version 0.4.7
 *  Fix: show button to activate/deactivate in footer again.
 * Version 0.4.6
 *  Revert input detection to onkeyup, as "input" event missed kana input
 * Version 0.4.5
 *  Consider user-defined synonyms for the meaning of a vocab/kanji/radical as well
 *  Further prevent double commits by using the "input" element's "input" event instead of the "onkeyup" function
 * Version 0.4.4
 *  Bugfix: correctly detect double-check from lightning mode
 * Version 0.4.3
 *  Bugfix: prevent a double commit when typing fast, which led to a shaking input window or in the worst case to
 *   wrong input.
 * Version 0.4.2
 *  Quickfix: adapt to Wanikani update, which was deployed on March 27th, 2023
 *   (see https://community.wanikani.com/t/updates-to-lessons-reviews-and-extra-study/60912)
 *   - removed jStorage and jQuery references
 *   - changed the @match for the new lesson and review urls
 *   - Note: did not check with compatibilites of other user scripts (like Lightning mode or Katakana for On'yomi) yet.
 * Version 0.4.1
 *  Bugfix: call commit() at most one time for each item
 *   (see https://community.wanikani.com/t/userscript-auto-commit-the-end-of-the-enter-key/11825/64)
 * Version 0.4
 *  Compatibility with Lightning mode from the Double-Check userscript
 *  Compatibility with Katakana For On'yomi userscript
 * Version 0.3
 *  Script works now on the Lessons page too
 * Version 0.2
 *  Makes script work with Greasemonkey and Firefox
 * Version 0.1
 *  Initial version
 *
 */

/* jshint -W097 */
'use strict';

var activated = true;
var click_threshold = 600;

let expected_answers = [];
let synonyms = {};

var is_userscript_lightningmode_active = function () {
    /* Returns true if "Lightning Mode" from Userscript Double-Check is active */
    return Boolean(document.querySelector('.doublecheck-active'));
};

var toggle = function () {
    var button = document.querySelector("#WKAUTOCOMMIT_button");
    if (activated) {
        // Deactivates WK Auto Commit mode
        button.title = "Switch auto commit on";
        button.style.opacity = 0.5;
        button.textContent = "Auto Commit is off";
        activated = false;
    } else {
        // Activates WK Auto Commit mode
        button.title = "Switch auto commit off";
        button.style.opacity = 1.0;
        button.textContent = "Auto Commit is on";
        activated = true;
    }
};

var sanitize = function (str1) {
    var str2 = str1.replace(/\s/g, ''); // Removes Whitespaces
    str2 = str2.toLowerCase();
    return str2;
};

var commit = function () {
    if(!commit.usable) return;
    // Temporarily deactivate the commit function to prevent double commits
    commit.usable = false;
    const inputbutton = document.querySelector(".quiz-input__submit-button");
    inputbutton.click();
    if (!is_userscript_lightningmode_active()) {
        setTimeout(function(){ inputbutton.click();}, click_threshold);
    }

};

var check_input = function () {
        const currentresponse = document.querySelector("#user-response").value;
        //console.log("Checking Input", currentresponse, expected_answers);
        for (var i in expected_answers) {
            if (sanitize(currentresponse) === sanitize(expected_answers[i])) {
                commit();
                break;
            }
        }
};

var register_check_input = function () {
    var userinput = document.querySelector("#user-response");
    //userinput.addEventListener("input", function (event) {
    userinput.onkeyup = function (event) {
        if (activated) {
            check_input();
        }
    };
};

var addButton = function () {
    /* Define button */
    var button = document.querySelector("#WKAUTOCOMMIT_button");
    if (!button) {
        button = document.createElement("div");
        button.id = "WKAUTOCOMMIT_button";
        button.title = "Toggle Auto Commit Mode";
        button.textContent = "Auto Commit is on";
        button.style.backgroundColor = "#C55";
        button.style.opacity = 1;
        button.style.display = "inline-block";
        button.style.fontSize = "0.8125em";
        button.style.color = "#FFF";
        button.style.cursor = "pointer"
        button.style.padding = "10px";
        button.style.marginLeft = "10px";
        button.style.verticalAlign = "bottom";
        button.onclick = toggle;

        /* Prepend button to footer */
        var footer = document.querySelector(".quiz-footer");
        footer.appendChild(button);
    }
};

/* Load user synonyms. Load them only once. */
var loadSynonyms = function () {
    if (loadSynonyms.loaded) return;
    const dataUserSynonyms = document.querySelector('script[data-quiz-user-synonyms-target]');
    if (!dataUserSynonyms) return;
    synonyms = JSON.parse(dataUserSynonyms.innerHTML);
    loadSynonyms.loaded = true;
};

/* Save synonyms added by the user during the quiz session */
window.addEventListener("didUpdateUserSynonyms", function(event) {
    //console.log("Received didUpdateUserSynonyms event from WaniKani", event);
    synonyms[event.detail.subjectId] = event.detail.synonyms;
});

/* React on a willShowNextQuestion event, which is triggered by WaniKani when a new question is shown */
window.addEventListener("willShowNextQuestion", function(event) {
    //console.log("Received willShowNextQuestion event from WaniKani", event);
    register_check_input();
    addButton();
    loadSynonyms();

    /* Get expected answers from current item depending on the task (reading or meaning) */
    expected_answers = []
    const item = event.detail;
    const subject = item.subject;
    const acceptedKind = [ "alternative", "primary", "allowed" ];
    if (item.questionType === "meaning") {
        //console.table(subject.meanings);
        expected_answers = expected_answers.concat(subject.meanings.filter((e) => acceptedKind.includes(e.kind)).map((e) => e.text));
        const subjectSynonyms = (subject.id in synonyms) ? synonyms[subject.id] : [];
        expected_answers = expected_answers.concat(subjectSynonyms);
    } else if (item.questionType === "reading") {
        //console.table(subject.readings);
        expected_answers = expected_answers.concat(subject.readings.filter((e) => acceptedKind.includes(e.kind) && (subject.type !== 'Kanji' || subject.primary_reading_type === e.type)).map((e) => e.text));
    }

    // Make the commit function usable again
    commit.usable = true;
});

(function () {
    console.log('WK Auto Commit (a plugin for Wanikani): Initialized');
})();
6 Likes

Doesn’t seem to work right now, such a shame. WK really needs an offline app or something that can work standalone. I paid for a lifetime subscription and would much rather a permanent program on my computer that isn’t subject to being randomly updated without warning.
Edit: Thank you so much Agri! That works perfectly! :pray:

1 Like

This works beautifully for me. Thank you!

I found the Katakana For Onyomi userscript recently, which this script claims to be compatible with. This compatibility seems to have broken at some point down the line however, so I tried to fix it myself today. It is probably not the best solution, but it is a working solution. For anyone else who is also interested:

code

replace the sanitize function in the existing script with

// katakana for onyomi script integration
var kataToHira = {"メ": "め", "ム": "む", "ャ": "ゃ", "モ": "も", "ュ": "ゅ", "ヤ": "や", "ョ": "ょ", "ユ": "ゆ", "ラ": "ら", "ヨ": "よ", "ル": "る", "リ": "り", "ロ": "ろ", "レ": "れ", "ワ": "わ", "ン": "ん", "ヲ": "を", "ア": "あ", "イ": "い", "ウ": "う", "エ": "え", "カ": "か", "オ": "お", "キ": "き", "ガ": "が", "ク": "く", "ギ": "ぎ", "ケ": "け", "グ": "ぐ", "コ": "こ", "ゲ": "げ", "サ": "さ", "ゴ": "ご", "シ": "し", "ザ": "ざ", "ス": "す", "ジ": "じ", "セ": "せ", "ズ": "ず", "ソ": "そ", "ゼ": "ぜ", "タ": "た", "ゾ": "ぞ", "チ": "ち", "ダ": "だ", "ッ": "っ", "ヂ": "ぢ", "ヅ": "づ", "ツ": "つ", "デ": "で", "テ": "て", "ド": "ど", "ト": "と", "ニ": "に", "ナ": "な", "ネ": "ね", "ヌ": "ぬ", "ハ": "は", "ノ": "の", "パ": "ぱ", "バ": "ば", "ビ": "び", "ヒ": "ひ", "フ": "ふ", "ピ": "ぴ", "プ": "ぷ", "ブ": "ぶ", "ベ": "べ", "ヘ": "へ", "ホ": "ほ", "ペ": "ぺ", "ポ": "ぽ", "ボ": "ぼ", "ミ": "み", "マ": "ま"};
function convertToHira(s)
    {
        return s.split('').map(c=>kataToHira[c] || c).join('')
    }

var sanitize = function (str1) {
    var str2 = str1.replace(/\s/g, ''); // Removes Whitespaces
    str2 = str2.toLowerCase();
    if(str2.length !== 0 && kataToHira[str2[0]])
    {
        str2 = convertToHira(str2)
    }
    return str2;
};
1 Like

THANK YOU BRO! i have been lagging behind on my wanikani for so long now, i cant thank you enough for the help i was getting desperate fr. drop me your user and let me pay you a Kofi for your troubles. or a paypal info if you have.

1 Like

I’m good on money lol. Glad it helped though!

2 Likes

alright bro but if this code gets messed up again cuz of changes in wanikani and you make another fix, you’ll have to give me that info so i can send ya at least something :wink:

1 Like

I sometimes want to turn it off, to either check the kanji’s info or different synonyms or combine it with “Auto commit Fixed” script, can you create a keybind / hotkey / keyboard shortcut for me to turn it off and on as I please while typing in an answer?