Wanikani: Review Queue SRS Breakdown

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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