Wanikani Lesson and Review Button Scaler

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

目前為 2022-03-29 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Wanikani Lesson and Review Button Scaler
// @namespace    http://tampermonkey.net/
// @version      0.13
// @description  Resizes the lessons and reviews buttons on the dashboard to scale with the number of lessons and reviews in the queues respectively.
// @author       Wantitled
// @include      https://www.wanikani.com/dashboard
// @include      https://www.wanikani.com/
// @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";
    });
};

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址