Self-study quiz button

Adds a quiz button to the sitemap menu (one click access)

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Advertisement:

// ==UserScript==
// @name         Self-study quiz button
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a quiz button to the sitemap menu (one click access)
// @author       Skymaiden
// @include     /^https://(www|preview).wanikani.com//
// @exclude     /^https://(www|preview).wanikani.com/(review|lesson)/
// @grant        none
// ==/UserScript==
/* jshint esversion: 6 */

(function() {
    'use strict';

    const sitemapMenu = document.querySelector('.sitemap');

    const buttonContent = document.createElement('a');
    buttonContent.href = '#';
    buttonContent.innerText = 'Quiz';
    buttonContent.style.paddingLeft = '14px';
    buttonContent.style.marginLeft = '8px';
    buttonContent.addEventListener('click', function() {
        if (window.ss_quiz && window.ss_quiz.open) {
            window.ss_quiz.open();
        } else {
            console.warn('Please install the Self-Study Quiz script');
        }
    });

    const button = document.createElement('li');
    button.classList.add('sitemap__section', 'navigation-shortcut');
    button.append(buttonContent);

    sitemapMenu.prepend(button);
})();