| // ==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