Wanikani: Review Queue SRS Breakdown

Adds a display showing how many items of each SRS stage there are in your queue

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 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: Review Queue SRS Breakdown
// @namespace    http://tampermonkey.net/
// @version      1.0.8
// @description  Adds a display showing how many items of each SRS stage there are in your queue
// @author       Kumirei
// @match        https://www.wanikani.com/*
// @match        https://preview.wanikani.com/*
// @require      https://greasyfork.org/scripts/462049-wanikani-queue-manipulator/code/WaniKani%20Queue%20Manipulator.user.js?version=1340063
// @grant        none
// ==/UserScript==

;(function () {
    wkQueue.on('review').addPostprocessing(update)
    window.addEventListener('didCompleteSubject', async () => update(await wkQueue.currentReviewQueue()))

    function update(queue) {
        const counts = get_counts(queue)
        const text = `[${counts.slice(1, 5).join(', ')}][${counts.slice(5, 7).join(', ')}][${counts[7]}][${counts[8]}]`
        document.querySelector('#srs_breakdown')?.remove()

        const elem = `<div id="srs_breakdown" style="position: absolute; top: 2em; right: 24px;">${text}</div>`
        document.querySelector('.character-header__menu-statistics').insertAdjacentHTML('beforeend', elem)
    }

    function get_counts(queue) {
        return queue
            .map((item) => item.srs)
            .reduce((counts, srs) => {
                counts[srs]++
                return counts
            }, new Array(9).fill(0))
    }
})()