Wanikani Lesson and Review Button Scaler

Scales the lessons and reviews buttons on the dashboard to scale with the number of lessons and reviews in the queues respectively.

Від 29.03.2022. Дивіться остання версія.

// ==UserScript==
// @name         Wanikani Lesson and Review Button Scaler
// @namespace    http://tampermonkey.net/
// @version      0.12
// @description  Scales the lessons and reviews buttons on the dashboard to scale with the number of lessons and reviews in the queues respectively.
// @author       Wantitled
// @match        https://www.wanikani.com/dashboard
// @grant        none
// @license      MIT
// ==/UserScript==


var buttonsContainer = document.getElementsByClassName("lessons-and-reviews")[0];
var boxes = jQuery(buttonsContainer).find("a");
boxes.each(function(index,elem){replaceStyle(elem)});

function replaceStyle(elem){
    let span = elem.children[0]
    let lrCount = parseInt(span.innerHTML, 10);
    setGrid();
    elem.style.backgroundPosition = "top";
    if (lrCount <= 6){
        elem.style.padding = "16px 16px 16px";
        let imageSize = Math.round(50 * 1.25);
        elem.style.backgroundSize = `auto ${imageSize}px`;
    } else {
        let marginSize = Math.round(lrCount * 2.762);
        //3.571
        let imageSize = Math.round(150*(lrCount/42));
        elem.style.padding = `${marginSize}px 16px 16px`;
        elem.style.backgroundSize = `auto ${imageSize}px`;
    }
}

function setGrid(){
    let gridContainer = document.querySelectorAll('.progress-and-forecast.progress-and-forecast--with-extra-study');
    gridContainer.forEach(gridElem => {
        gridElem.style.gridTemplateRows = "auto auto";
    });
};