Wanikani Random Font II

The script changes the font for questions in Wanikani reviews into randomly selected from list, allowing you to practice various typefaces and forms of the kanji. Based on Wanikani Random Font script by Mempo. Before using, edit the list or install fonts specified there!

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        Wanikani Random Font II
// @namespace   wanikanirandomfontii
// @description The script changes the font for questions in Wanikani reviews into randomly selected from list, allowing you to practice various typefaces and forms of the kanji. Based on Wanikani Random Font script by Mempo. Before using, edit the list or install fonts specified there!
// @include     http://www.wanikani.com/review/session
// @include     https://www.wanikani.com/review/session
// @version     1.0.0
// @grant       none
// ==/UserScript==

// Thanks go to:
//   - Mempo, the author of the original script
//   - Google and Stackoverflow, since I know nothing about JS and WEB dev :)

$(function() {
    // Fonts list - add yours, delete those you don't have
    var fonts = [
        "EPSON 教科書体M",
        "EPSON 正楷書体M",
        "EPSON 行書体M",
        "藍原筆文字楷書",
        "青柳隷書SIMO2_T",
        "英椎楷書",
        "いろはマルみかみ Light",
        "無心",
        "RAKO_FONT",
        "nukamiso",
        "仕事メモ書き",
        "さなフォン悠",
        "春夏秋冬ⅡB",
        null            // To get the default one occasionally
        ];

    // Change the font randomly and show the original one on mouse hover
    var randomFont = function() {
        var chosen = fonts[Math.floor(Math.random() * fonts.length)];
        var jpElem = document.getElementById('character').firstElementChild;

        jpElem.style.fontFamily = chosen;

        jpElem.onmouseover = function() {
	        jpElem.style.fontFamily = null;
        }

        jpElem.onmouseout = function() {
	        jpElem.style.fontFamily = chosen;
        }
    };   
    
    var o = new MutationObserver(randomFont);
    o.observe(document.getElementById('character'), {'attributes' : true});
});