Last active
August 29, 2015 14:04
-
-
Save fasiha/3c22598ae3c457ada00a to your computer and use it in GitHub Desktop.
Show Tangorin.com's kanji stroke order in Koohii kanji study section (Chrome Tampermonkey & Firefox Greasemonkey script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Koohii Study section stroke order | |
// @namespace koohiistudy | |
// @version 0.1 | |
// @description Adds Tangorin kanji stroke order, and expands Sample Words | |
// @match http://kanji.koohii.com/study/kanji* | |
// @match https://kanji.koohii.com/study/kanji* | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
// For background see http://forum.koohii.com/viewtopic.php?id=12074 | |
var stroke_container = ".k-sod"; | |
var inject_container = document.createElement("div"); | |
document.querySelector("#EditStoryComponent").appendChild(inject_container); | |
GM_xmlhttpRequest({ | |
method: "GET", | |
url: "http://www.ig.gmodules.com/gadgets/proxy/refresh=31556926&container=ig/http://tangorin.com/kanji/"+document.querySelector("div.kanji>span").textContent, | |
onload: function(response) { | |
var responseHTML = new DOMParser().parseFromString(response.responseText, "text/html"); | |
inject_container.innerHTML = "<br />" + responseHTML.documentElement.querySelector(stroke_container).innerHTML; | |
}; | |
}); | |
// Via http://stackoverflow.com/a/13734859 | |
function GM_main () { | |
window.onload = function () { | |
App.StudyPage.toggleDictionary(); | |
}; | |
} | |
addJS_Node (null, null, GM_main); | |
//-- This is a standard-ish utility function: | |
function addJS_Node (text, s_URL, funcToRun, runOnLoad) { | |
var D = document; | |
var scriptNode = D.createElement ('script'); | |
if (runOnLoad) { | |
scriptNode.addEventListener ("load", runOnLoad, false); | |
} | |
scriptNode.type = "text/javascript"; | |
if (text) scriptNode.textContent = text; | |
if (s_URL) scriptNode.src = s_URL; | |
if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()'; | |
var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement; | |
targ.appendChild (scriptNode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment