您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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.4.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/* // @grant none // @supportURL https://community.wanikani.com/t/what-do-you-want-now-request-extensions-here/3838/1787 // ==/UserScript== (function() { 'use strict'; /* global wkof */ let scriptId = 'show_total_lesson_count'; let scriptName = 'Show Total Lesson Count'; let wkBatchSize = 0; let initial_load = true; let todaysLessonsCount; let settings; let stateStarting = false; let todaysLessonsFrameLoaded = false; let navBarCountFrameLoaded = false; if (!window.wkof) { if (confirm(scriptName + ' 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; } const wkofTurboEventsScriptUrl = 'https://update.gf.qytechs.cn/scripts/501980/1419628/Wanikani%20Open%20Framework%20Turbo%20Events.user.js'; wkof.load_script(wkofTurboEventsScriptUrl, /* use_cache */ true) wkof.ready('TurboEvents').then(() => { let urlList = [wkof.turbo.common.locations.dashboard, wkof.turbo.common.locations.items_pages, /^https:\/\/www\.wanikani\.com\/(settings|level|radicals|kanji|vocabulary)(\/|\?difficulty=).+\/?$/]; wkof.turbo.on.common.urls(() => { initial_load = stateStarting = true; todaysLessonsFrameLoaded = navBarCountFrameLoaded = false; _start(); }, urlList); wkof.turbo.on.event.before_frame_render((e) => { if (['todays-lessons-frame', 'lesson-and-review-count-frame'].includes(e.target.id)) { todaysLessonsFrameLoaded = false; navBarCountFrameLoaded = false; } }, { urls: urlList, noTimeout: true }); wkof.turbo.on.event.frame_load(async (e) => { if (e.target.id === 'todays-lessons-frame') { todaysLessonsFrameLoaded = true; await main(); } else if (e.target.id === 'lesson-and-review-count-frame') { navBarCountFrameLoaded = true; await main(); } }, { urls: urlList }); }); function _start() { wkof.include('Settings, Menu, Apiv2'); wkof.ready('Settings, Menu, Apiv2').then(loadSettings).then(insertMenu).then(main); } function loadSettings() { wkBatchSize = wkof.user.preferences.lessons_batch_size; let defaults = { showTotalOnly: false, setOwnPreferredDaily: false, preferredDailyAmount: wkBatchSize * 3 }; return wkof.Settings.load(scriptId, defaults).then(function(wkof_settings) {settings = wkof_settings;}); } function insertMenu() { let config = { name: scriptId, submenu: 'Settings', title: scriptName, on_click: openSettings }; wkof.Menu.insert_script_link(config); } function openSettings() { let config = { script_id: scriptId, title: scriptName, on_save: main, content: { showTotalOnly: { type: 'checkbox', label: 'Show Only Total Lesson Count', hover_tip: `Changes display between "<today's lesson count> / <total lesson count>" and just "<total lesson count>"`, default: false }, setOwnPreferredDaily: { type: 'checkbox', label: 'Set Your Own Daily Lesson Count', hover_tip: `Choose whether to display the value you set as your daily lesson count or not`, default: false }, preferredDailyAmount: { type: 'number', label: 'Preferred Daily Lesson Amount', hover_tip: `The number you want displayed for "Today's Lessons". Maximum of batch size * 3. NOTE: this does not actually change the number of available lessons.`, default: wkBatchSize * 3, min: 0, max: wkBatchSize * 3 } } }; let dialog = new wkof.Settings(config); dialog.open(); } async function getCountContainers() { let dashboardTileCountContainer = document.querySelector('.todays-lessons__count-text .count-bubble'); let navBarCountContainer = document.querySelector('.lesson-and-review-count__count'); if (initial_load && (dashboardTileCountContainer || navBarCountContainer)) { let container = dashboardTileCountContainer ?? navBarCountContainer; todaysLessonsCount = parseInt(container.textContent); initial_load = false; } return [dashboardTileCountContainer, navBarCountContainer]; } async function main() { if (!settings) { if (!stateStarting) { stateStarting = true; setTimeout(_start, 50); } return; } stateStarting = false; let summary_data = await wkof.Apiv2.get_endpoint('summary'); let totalLessonCount = summary_data.lessons[0].subject_ids.length; let lessonCountContainers; if (todaysLessonsFrameLoaded || navBarCountFrameLoaded) lessonCountContainers = await getCountContainers(); else return; let todaysCountForDisplay = todaysLessonsCount; if (lessonCountContainers.every(node => node == null)) return; if (isNaN(todaysLessonsCount)) { todaysCountForDisplay = 0; } else { if (settings.setOwnPreferredDaily) todaysCountForDisplay = todaysLessonsCount - (wkBatchSize * 3 - settings.preferredDailyAmount); } if (lessonCountContainers[0]) lessonCountContainers[0].textContent = settings.showTotalOnly ? totalLessonCount : todaysCountForDisplay + ' / ' + totalLessonCount; if (lessonCountContainers[1]) lessonCountContainers[1].textContent = settings.showTotalOnly ? totalLessonCount : todaysCountForDisplay; if (todaysCountForDisplay === 0) { // hide the start button if it is not already, TODO: disable nav bar button if it is not already let startButton = document.querySelector('.todays-lessons-button--start') if (startButton && startButton.checkVisibility()) { startButton.style['display'] = 'none'; } } // hide "Today's" subtitle let lessonSubtitle = document.querySelector('.todays-lessons__subtitle'); if (lessonSubtitle && lessonSubtitle.checkVisibility()) { lessonSubtitle.style['display'] = 'none'; } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址