Wanikani: Review Queue SRS Breakdown

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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