One of my favorite scripts on WK is the Egg Timer by @horusscope, but it had a lot of problems that I just started fixing over time. Now it looks so different that I figured I share it with the rest of you all. What the egg timer does is track how much time you’ve spent on your review, which then carries over to the review summary page. This is useful if you want to track how much time you’re spending on WK everyday. So what’s different in this version?
FEATURES, BUG FIXES, AND IMPROVEMENTS
Fixed timer accuracy. Timer now corresponds to the actual time instead of CPU refresh rate.
Review duration now shows up properly on the summary page.
Timer no longer resets when the page is refreshed. Timer will reset after user reaches the review summary page.
Timer will also reset 15 minutes after the review window is closed.
Added a button that blends in naturally with WK’s own UI.
Added a hotkey (‘T’-key) to toggle the visibility of the timer.
Added documentation to the script to improve readability.
Major UI improvements. The timer is less distracting and blends in with WK’s UI.
To Access: (1) Be on WK Website. (2) Click on Profile Picture (3) Scripts → Settings → Review Timer. (Info) These settings allows users to move button position, change to the classic button, change button color (if using classic), and remove the button entirely…
FUTURE UPDATES
Currently only tracks the latest review, a future update will track all reviews beyond that update, and derive statistics based on that data.
I think that this is a mistake. There are numerous ways of exiting a session which doesn’t include the summary page. How about listening to current item keychange and setting a time limit?
Yeah I’ve been thinking about how to do a more foolproof method, but I might have to sit on it for a while. The good news is that if you try to enter a review after some amount of time, you’ll be taken to the review summary page first. And if you try to enter in less than that, well you could kind of consider that the same session. But yeah, that’s on the TODO list.
LOL. I didn’t even think about that. In that case, I might encode a hard time-span buffer. Such as if you aren’t on the review page for longer than 15 minutes, the timer will reset.
to me this is a timer (think kitchen timer)
but it seems you want a chrono? maybe you should even rename the script, as I was expecting it to be a way to set a session timeout.
A session timeout? I wouldn’t mind adding that in a toggle-able functionality. If I understand you correctly, you’d like something that would automatically end your review session after a certain amount of time?
Your script is really useful. I noticed it logs to the console at startup and updates the DOM every second during reviews, even when the timer is hidden. This makes developing other scripts while it is enabled a bit harder. Below is a patch which modifies it to not print to the console and to only update the DOM if the timer is visible, in case you are interested in incorporating these changes.
@@ -4,7 +4,7 @@
// @description Egg timer overhaul. Tracks how long you've been doing your review for. See the original here: https://greasyfork.org/en/scripts/16316-wanikani-egg-timer
// @include http://www.wanikani.com/*
// @include https://www.wanikani.com/*
-// @version 1.03
+// @version 1.04
// original author...
// @author Horus Scope
// edited by...
@@ -42,6 +42,13 @@
+ (seconds? seconds+"s" : "");
}
+function update_all() {
+ update();
+ if (window.localStorage.eggtimer_pinned=='true') {
+ timeSpan.textContent = "Time Elapsed: " + window.localStorage.eggtimer_data;
+ }
+}
+
// ===========================================================================================================================================
// Generates text element.
@@ -66,6 +73,7 @@
pinned = false;
else pinned = (pinned == "true" ? false : true);
window.localStorage.eggtimer_pinned = pinned;
+ update_all(); // timer would be out of date until next time setInterval task runs if we didn't do this
timeSpan.style.cssText = pinned ? "display: block;" : "display: none;";
timeSpan.style.cssText += " color: rgb(200,200,200); font-family: HonyaJi-Re; text-align:center; margin-top: 20px";
}
@@ -129,9 +137,9 @@
on_click: menu_open
};
- console.log('SCRIPT-WK_Review_Timer> setting: position = ' + wkof.settings.review_timer.position);
- console.log('SCRIPT-WK_Review_Timer> setting: button_type = ' + wkof.settings.review_timer.button_type);
- console.log('SCRIPT-WK_Review_Timer> setting: classic_color = ' + wkof.settings.review_timer.classic_color);
+ // console.log('SCRIPT-WK_Review_Timer> setting: position = ' + wkof.settings.review_timer.position);
+ // console.log('SCRIPT-WK_Review_Timer> setting: button_type = ' + wkof.settings.review_timer.button_type);
+ // console.log('SCRIPT-WK_Review_Timer> setting: classic_color = ' + wkof.settings.review_timer.classic_color);
wkof.Menu.insert_script_link(menu);
}
@@ -280,7 +288,7 @@
timeSpan.style.cssText += " color: rgb(200,200,200); font-family: 'Sans'; text-align:center; margin-top: 20px";
// Update timer and text once every second
- setInterval(function() {update(); timeSpan.textContent = "Time Elapsed: " + window.localStorage.eggtimer_data;}, 1000);
+ setInterval(update_all, 1000);
}
else if (/review/i.exec(window.location.pathname)) // Executes if on summary page.
{