[Userscript] WaniKani Lesson Hover Details

I think something like “Previous Levels” would work fine. It’s a bit longer, but pretty clear shrug

1 Like

I do wish that the setting said something like “sort lessons by level (ascending), then by subject” but I’m probably the only person in the world able to misunderstand the current wording! <laugh>

1 Like

Here’s an updated patch per this discussion. Please let me know if you’d prefer that I maintain it as a separate script.

Current display:

Patch
diff --git a/bundle.user.js b/bundle.user.js
index 832acc6..f8008f0 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;
@@ -108,18 +119,30 @@
   }

   function getPopoverHtml(lessonCounts) {
+    const total =
+      lessonCounts.radical + lessonCounts.kanji + lessonCounts.vocabulary;
     return `<div class="lhd-table">
+  <div class="lhd-row">
+    <div class="lhd-cell lhd-cell-title">Prev Lvl</div>
+    <div class="lhd-cell lhd-cell-value">${
+      lessonCounts.ascending.radical +
+      lessonCounts.ascending.kanji +
+      lessonCounts.ascending.vocabulary
+    }/${total} (${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>
+		<div class="lhd-cell lhd-cell-value">${lessonCounts.radical}/${total}</div>
 	</div>
 	<div class="lhd-row">
 		<div class="lhd-cell lhd-cell-title">Kanji</div>
-		<div class="lhd-cell lhd-cell-value">${lessonCounts.kanji}</div>
+		<div class="lhd-cell lhd-cell-value">${lessonCounts.kanji}/${total}</div>
 	</div>
 	<div class="lhd-row">
 		<div class="lhd-cell lhd-cell-title">Vocab</div>
-		<div class="lhd-cell lhd-cell-value">${lessonCounts.vocabulary}</div>
+		<div class="lhd-cell lhd-cell-value">${lessonCounts.vocabulary}/${total}</div>
 	</div>
 </div>`;
   }
1 Like

I’ll take a look at your change sometime in the next week or so. If the change is simple I’ll probably make it in my copy, though I’m likely to change the format.

1 Like

What decision did you end up making?

I forgot about it to be honest. Is this a feature you’d like to see as well? If I make the change it would look something like this, not like how @Rrwrex made it.

image

What do you think?

1 Like

FWIW, I’d rather see the number of previous level in parens and have to do the math in my head for current level. I just want to know when I’ll start seeing current level items.

Also, for me the total prior level has always equaled the prior level vocabulary. I suspect it’s the same for everyone, so losing the total shouldn’t be a big deal.

I figured as much, but to me putting “current” in parentheses is more logical. There also hasn’t been anyone clamoring for this feature, so it may make more sense to just let you maintain your own version and not change the official version. I’ll have to see what @UInt2048 thinks as well since they are the only other person asking about this.

Pretty much the only time there’d be prior radicals and kanji is when new lessons are added or moved after you’re past a level, which is why I have prior items for all three.

Well, how many people have asked for the number of current level items?

Logical to me would be a choice between leaving it as is or adding previous counts. Not adding current counts.

Your call, of course.

Zero, but developers don’t usually add features just because one person asks for them either. :slight_smile: If you won’t find the current level items useful I’ll probably just leave it as-is.

Developers are prone to off by one errors, too. :wink:

(And I’m fine maintaining my own version for myself. @UInt2048 pinged you about the feature, not me.)

1 Like

I got bored and decided to make it configurable (by editing the script). Default setting shows current level counts in parentheses, but with options for “None” (current behavior) and “Prior Levels” as well. You can check out the code below if you want since I still haven’t decided whether or not to publish it.

@UInt2048 let me know what you think as well.

2 Likes

That’s pretty neat! I think the current level phrasing makes more sense as well!

As for @Rrwrex commenting that it’s always vocab, don’t forget that WK can and will move/add radicals and kanji

1 Like

So you’d get value out of seeing the current level amounts in parentheses compared to the current version where there’s just a total per type?

Yes, I would. I like to make sure I’m finished with N-1 before leveling up to N+1 so I know I am not abusing reordering. I think a feature like this could help with that.

Just for me, when I’m on desktop, I enjoy looking at all the stats, so I think it would add more of a synergy (especially with the Review Hover Details giving a full level breakdown of reviews)

That being said, other scripts (such as my own) could technically provide this information, so it isn’t critical if you really didn’t want to add/maintain this.

I’m not following. There must be some post-level-60 thing I’m not groking.

Before leveling up, aren’t all of the items you wish to finish normally “current level”? (Ignoring WK moves/adds.)

And for several days after leveling up, aren’t the “N-1” items prior level items that you want to finish before starting on the current level (“N+1”) items?

It’s a reorder script thing. When people don’t use a reorder script responsibly they can basically skip all vocab from all levels. So you have to be careful to not get too behind when using a script like that.

2 Likes

At this very moment, I’m on level 32 (N). Before I level up to 33 (N+1), I want to have completed at least all level 31 (N-1) vocabulary even if I hadn’t had a 0/0 this level, since reordering makes it possible to not have done so (level-up merely requires 90% of kanji, which on “slow” levels requires at least one radical, but never any vocab)

Like Seanblue said, I have never been level 60. It’s the reordering.

(emphasis mine)

I should probably install a reordering script just to understand it better (I’m still confused). Sorry to be dense, but I want to understand. Does your lesson queue currently have anything other than level 31 and 32 items?

Are you saying that when you level up to 33, you might have both level 32 and level 31 vocab still in your lesson queue? Genuine curiosity, no snark: if that’s possible but you don’t want it to happen, why do you use reordering? I’m missing something. Don’t the reordering scripts still allow you to order lessons by level (in ascending order)?

This seems completely alien to me: at no point have I ever had more than two levels of items in my lesson queue (ignoring WK adds/moves).

[I find a _lot_ of value doing all the vocab for a level before proceeding (if I understand you correctly, you do, too). Frankly, my understanding would be _much_ worse if I somehow allowed _lessons_ from prior levels to accumulate.]

Maybe a concrete example would help me understand better. What does your level 32 lesson queue look like right now?

In my case, I leveled up to 44 a few days ago, but have only unlocked the first batch of kanji on level 44. I’ve completed all my lessons for level 43 vocabulary. At the moment I see:

For me right now, it would be redundant to display “current level” counts in parentheses because 100% are “current level”. Once I guru 90% of the level 44 items, I’ll level up, unlocking level 45 items. At that point, my lesson queue will contain previous level (n-1, level 44) vocabulary items and the first batch of r/k from level 45 (n). At that point, the previous level (44) count is still more interesting than the current level (45) count, though, no?

Prior counts tell me how many more lessons I need to do before I’ll start seeing level 45 items. They let me know when level 45 will really start. Total counts (prior + current) are also informative, as they tell me when I’m likely to level up and the types of items I’ll see. But I still don’t understand the use for current level counts. Current is normal, it’s the others I want to know about.

What does your lesson queue look like currently, and what will it look like when you get to 33? How would you use “current level” counts differently than the total counts? Why is current more informative than prior?

Sorry for the long post and so many questions, but I’d like to understand.

Exactly

It’s empty (but I don’t always get to this in a level)

If you wanted a concrete example from earlier: 30 vocab L31 + 30 vocab L32 + nothing else