WaniKani has a hard coded 1.5 second to 1.8 second minimum for how long the loading screen is shown when starting lessons/reviews. Even if the page content loads faster than that, the loading screen won’t go away until after the delay. This script removes the delay, making the loading screen disappear faster. Removing the delay doesn’t obviously seem to break anything, but maybe they had some reason for keeping it @koichi @viet?
To install this script, just create a new script in your script manager and paste the text below into it.
// ==UserScript==
// @name WK Load Faster
// @namespace est_fills_cando
// @version 0.2
// @description Brings the loading screen down more quickly, removing the mandatory 1.8 second delay.
// @author est_fills_cando
// @match https://www.wanikani.com/review/session
// @match https://www.wanikani.com/lesson/start
// @match https://www.wanikani.com/lesson/session
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// WK doesnn't make the loading screen removal method global in lessons for some reason
// so we patch jQuery with a proxy that lets us modify the behavior of the method in
// both lessons/reviews by detecting its calls to jQuery and modifying the behavior of jQuery
// to do what we want
function proxy_jquery() {
let jq = window.jQuery;
delete window.jQuery;
window.jQuery = jq;
let pt = window.jQuery.prototype;
// returns true if given jQuery object is the loading screen
function is_loading_screen(jqobj) {
return jqobj.length == 1 && ['loading-screen','loading'].includes(jqobj.get(0).id);
}
let old_delay = pt.delay;
pt.delay = function() {
if (is_loading_screen(this))
return this;
else
return old_delay.call(this,...arguments);
}
let old_fadeOut = pt.fadeOut;
pt.fadeOut = function() {
if (is_loading_screen(this)) {
return old_fadeOut.call(this,0);
}
else
return old_fadeOut.call(this,...arguments);
}
}
// patch jQuery if it was already loaded or immediately after it loads
// to do what we want
if (window.jQuery) {
proxy_jquery()
} else {
let _jQuery = undefined;
Object.defineProperty(window, "jQuery", {
get: () => _jQuery,
set: function(data) {_jQuery = data; proxy_jquery()},
configurable: true,
enumerable: true
});
}
})();
History
- v0.1: works for reviews only
- v0.2: works for lessons and reviews