Changes the count of lessons on the Today's Lessons tile to show the total number of available lessons in addition to the number selected for you
当前为
// ==UserScript==
// @name Show Total Lesson Count - WaniKani
// @namespace http://tampermonkey.net/
// @version 0.2.1
// @description Changes the count of lessons on the Today's Lessons tile to show the total number of available lessons in addition to the number selected for you
// @license MIT
// @author LupoMikti
// @match https://www.wanikani.com
// @match https://www.wanikani.com/dashboard
// @grant none
// ==/UserScript==
(function() {
'use strict';
/* global wkof */
if (!window.wkof) {
if (confirm('Show Total Lesson Count requires Wanikani Open Framework.\nDo you want to be forwarded to the installation instructions?')) {
window.location.href = 'https://community.wanikani.com/t/instructions-installing-wanikani-open-framework/28549';
}
return;
}
wkof.include('Apiv2');
wkof.ready('Apiv2').then(main);
async function main() {
let summary_data = await wkof.Apiv2.get_endpoint('summary');
let totalLessonCount = summary_data.lessons[0].subject_ids.length;
let lessonCountContainer = document.querySelector('.todays-lessons__count-text .count-bubble');
if (!lessonCountContainer) {
return;
}
let todaysLessonsCount = parseInt(lessonCountContainer.textContent, 10);
if (isNaN(todaysLessonsCount)) {
todaysLessonsCount = 0;
}
lessonCountContainer.textContent = todaysLessonsCount + ' / ' + totalLessonCount;
// hide "Today's" subtitle
let lessonSubtitle = document.querySelector('.todays-lessons__subtitle')
if (lessonSubtitle && lessonSubtitle.checkVisibility()) {
lessonSubtitle.style['display'] = 'none';
}
}
})();