[Userscript] WaniKani Lesson Hover Details

Hi @seanblue. Thanks for this useful little script!

I wanted to add “ascending” item information to the popup (per this thread), so I created the following patch.

Would you prefer that I maintain it as a separate script, or would you be willing to include it as a new version of the original? I tried to follow your coding style and I think it’s a useful addition. It now displays the following on my dashboard:

Here's the patch
diff --git a/bundle.user.js b/bundle.user.js
index 832acc6..6ce2dc5 100644
--- a/bundle.user.js
+++ b/bundle.user.js
@@ -3,7 +3,7 @@
 // @namespace     https://www.wanikani.com
 // @description   Show lesson breakdown by type on hover
 // @author        seanblue
-// @version       1.1.0
+// @version       1.1.1-rw
 // @include       https://www.wanikani.com/*
 // @grant         none
 // ==/UserScript==
@@ -51,15 +51,18 @@
   wkof.include("Apiv2");
   wkof.ready("Apiv2").then(fetchData);

+  let userLevel = 0;
+
   function fetchData() {
     let promises = [];
     promises.push(wkof.Apiv2.get_endpoint("summary"));
     promises.push(wkof.Apiv2.get_endpoint("subjects"));
-
+    promises.push(wkof.Apiv2.get_endpoint("user"));
     Promise.all(promises).then(processData);
   }

   function processData(results) {
+    userLevel = results[2].level;
     let lessonCounts = getLessonCount(results);
     setupMenuPopover(lessonCounts);
     setupDashboardPopover(lessonCounts);
@@ -73,6 +76,11 @@
       radical: 0,
       kanji: 0,
       vocabulary: 0,
+      ascending: {
+        radical: 0,
+        kanji: 0,
+        vocabulary: 0,
+      },
     };

     // Pull the list of subject_ids from the lesson list in 'summary'.
@@ -80,6 +88,9 @@
     lessonSubjectIds.forEach(function (subjectId) {
       let item = subjects[subjectId];
       lessonCounts[item.object]++;
+      if (item.data.level === userLevel - 1) {
+        lessonCounts.ascending[item.object]++;
+      }
     });

     return lessonCounts;
@@ -109,6 +120,16 @@

   function getPopoverHtml(lessonCounts) {
     return `<div class="lhd-table">
+  <div class="lhd-row">
+    <div class="lhd-cell lhd-cell-title">Ascending</div>
+    <div class="lhd-cell lhd-cell-value">${
+      lessonCounts.ascending.radical +
+      lessonCounts.ascending.kanji +
+      lessonCounts.ascending.vocabulary
+    } (${lessonCounts.ascending.radical}r • ${
+      lessonCounts.ascending.kanji
+    }k • ${lessonCounts.ascending.vocabulary}v)</div>
+  </div>
 	<div class="lhd-row">
 		<div class="lhd-cell lhd-cell-title">Radicals</div>
 		<div class="lhd-cell lhd-cell-value">${lessonCounts.radical}</div>