Greasy Fork

Greasy Fork is available in English.

WaniKani Nippongrammar Extension

Svg Canvas used to draw Kanji on reviews and lessons, using website code.

当前为 2015-08-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         WaniKani Nippongrammar Extension
// @namespace    WK-nippongrammar
// @version      0.1
// @website      http://nippongrammar.appspot.com/
// @description  Svg Canvas used to draw Kanji on reviews and lessons, using website code.
// @author       Code by Aaron Drew, Wanikani adaption by Ethan McCoy
// @include      *.wanikani.com/review/session*
// @include      *.wanikani.com/lesson/session*
// @grant        none
// run-at       document-end
// @license        MIT
// ==/UserScript==

$("head").prepend('<script type="text/javascript" src="http://greasyfork.icu/scripts/11949-kanjisvg/code/kanjiSvg.js?version=69799"></script>');
$("head").prepend('<script type="text/javascript" src="http://greasyfork.icu/scripts/11951-kanjirender/code/kanjirender.js"></script>');


function handleKeyChange(key, action){
    
    console.group("animate strokes userscript"),
console.log("key", key),
    cur = $.jStorage.get(key),
    text = cur.voc || cur.kan || cur.rad || "",
    console.log("text", text);

    strokeDiv = document.getElementById('strokeChar') || document.createElement('div'), strokeDiv.style.padding = "20px 20px 0", strokeDiv.id = "strokeChar";
        
    if (key === "l/currentLesson" || key === "l/currentQuizItem"){
        //console.log(charDiv.childNodes[0].nodeType === 3),
        
        charDiv = document.getElementById("character");
        
        meaningDiv = document.getElementById("meaning");
        
        console.log("parent", charDiv.parentNode);
        

        }else{
            
            //Reviews 'charDiv' is actually a span
            charDiv = document.getElementById("character").getElementsByTagName("span")[0];
        }
        charDiv.parentNode.insertBefore(strokeDiv, charDiv);
    
       // console.log("text for "+key+"?",[charDiv.childNodes[0].nodeType]),
//    itemSpan = charDiv.getElementsByTagName("span")[0];

    
        
    if(text.indexOf(".png") === -1){ //weed out picture radicals for now, extend svg library later
        strokeDiv && (strokeDiv.style.display = "block");
        animateWriting(text,'strokeChar',30),
        charDiv && (charDiv.style.display = "none");
    }else{
        strokeDiv && (strokeDiv.style.display = "none");
        charDiv && (charDiv.style.display = "block");
    }

console.groupEnd();
};

$.jStorage.listenKeyChange("currentItem", handleKeyChange);
$.jStorage.listenKeyChange("l/currentQuizItem", handleKeyChange);
$.jStorage.listenKeyChange("l/currentLesson", handleKeyChange);