Someone made a post about this a few days ago and I thought it was a great idea so I decided to quickly throw something together.
Basically, it turns this:
Into this:
When reviews are available. Similar to what other websites like gmail do when you have new mail.
Note: It uses html from the dashboard page to check this and not API calls, therefore it will only work on the dashboard. Also, JavaScript really isn’t my cup of tea, so it’s likely it can be done better. But as it is, it works and I find it really useful, so I decided to share it.
Turns out that the script stopped the lesson and the review sessions loading for whatever reason so I’ve just updated it to exclude them pages from loading the script. When I originally wrote it, I tried to get it so that it would only load on the dashboard but I couldn’t for the life of me get it to work. In the end I just wrote it so it would try to find the information it needed, and if it couldn’t find it, it would assume it wasn’t on the dashboard and stop checking for it. So I don’t really understand why it’s causing such a problem on those pages. Maybe someone a bit more adept at JS could solve the mystery.
tl;dr: Something went wrong so update the script or you won’t be able to do new lessons
// ==UserScript== // @name WaniKani Title Update // @namespace NeonPhoenix // @version 1.0 // @description Updates the title of the tab when you have reviews available on WaniKani // @author NeonPhoenix // @matchhttp://www.wanikani.com/ // @matchhttps://www.wanikani.com/ // @grant none // ==/UserScript==
Otherwise, it failed - and by that, I mean, half the header of the page elements disappeared. Lesson and review count, times, progression bar data, etc.
Kaimera said...
For firefox, I've had to alter the meta info to:
// ==UserScript== // @name WaniKani Title Update // @namespace NeonPhoenix // @version 1.0 // @description Updates the title of the tab when you have reviews available on WaniKani // @author NeonPhoenix // @match http://www.wanikani.com/ // @match https://www.wanikani.com/ // @grant none // ==/UserScript==
Otherwise, it failed - and by that, I mean, half the header of the page elements disappeared. Lesson and review count, times, progression bar data, etc.
Yeah I'm getting that too, yet I don't understand why it's doing it. The script also seems to stop me from quoting posts. Seems like my attempt at JavaScript was pretty bad.
It seems it has to do with the line that requires jQuery. Taking it out makes the page look normal again but jQuery is required for the script to work.
It worked perfectly fine for me earlier, and console.log is returning a valid reviewTime variable result rather than an undefined one.
Obviously WK is using Jquery, and userscripts can indeed conflict with two different versions of it - my only assumption here being that it’s using WK’s version rather than the one you were trying earlier (and in the onLoad method you used). GreaseMonkey in particular has some workaround for this, though it didn’t work for me when I tried it earlier hence why I ditched your onLoad method: http://wiki.greasespot.net/Third-Party_Libraries#Potential_conflict
I guess the best thing to do is wait for someone to do it better then. Like I said I really only made it as a quick useful thing for myself, and since it was working fine for me in chrome, I decided to share it.
Personally I opted for an alert, as it takes control of all browser tab focus and really gets 'in your face':
alert("The Crabigator is ready");
In place of the title change.
That would be helpful because I sometimes don't notice the title change. Very annoying if it pops up when you're playing a game or something though.
I did update the version on github to use raw javascript so now it works with firefox and doesn't cause any other problems, like not being able to quote posts.
Would that happen in Chrome? In firefox, the popup cannot force an alt-tab from a game(let alone outside of the browser focus) - not unless you’re playing a browser-based game, then I can see the issue.
Kaimera said...
Would that happen in Chrome? In firefox, the popup cannot force an alt-tab from a game(let alone outside of the browser focus) - not unless you're playing a browser-based game, then I can see the issue.
There are JS notification libraries (like the HTML5 notifications which were deprecated I believe), though in order to actually use them you need to request permission every session you’re on the site. These would instead display a more non-intrusive, unfocused notification to the lower right-corner of your screen of the size you desire.
Otherwise, maybe a moving title bar would be more noticeably? That’d require changing the interval a little, maybe with an eventListener. Other than that, perhaps playing a sound?