Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds kanji stroke order to the Study and Review sections of kanji.koohii.com. Works with Tampermonkey or Greasemonkey for Chrome or Firefox.
// ==UserScript==
// @name Kanji.koohii Stroke Order
// @namespace koohiistroke
// @description Adds kanji stroke order to the study and review sections on kanji.koohii.com - forked and modified from https://gist.github.com/shussekaido/3541ab70e37983f0360d
// @include http://kanji.koohii.com/study/kanji/*
// @include https://kanji.koohii.com/study/kanji/*
// @include http://kanji.koohii.com/review*
// @include https://kanji.koohii.com/review*
// @include http://staging.koohii.com/study/kanji/*
// @include https://staging.koohii.com/study/kanji/*
// @include http://staging.koohii.com/review*
// @include https://staging.koohii.com/review*
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @grant GM.xmlHttpRequest
// @grant GM_xmlhttpRequest
// @version 1.31
// @downloadURL https://gist.github.com/jealie/7569590bcb939a9bbd76c213a4b9f6bc/raw/koohiistroke.user.js
// ==/UserScript==
var stroke_container = ".k-sod";
var inject_container = document.createElement("div");
// Study section
if(window.location.href.indexOf("study") > -1) {
document.querySelector("#my-story .right").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(".kanji>span").textContent,
onload: function(response) {
var responseHTML = new DOMParser().parseFromString(response.responseText, "text/html");
inject_container.appendChild(responseHTML.documentElement.querySelector(stroke_container));
}
});
};
// Review section
if(window.location.href.indexOf("review") > -1) {
var target = document.querySelector('#uiFcMain');
document.querySelector("#rd-side").appendChild(inject_container);
var observer = new MutationObserver(function(mutations) {
if (document.querySelector(".uiFcCard").classList.contains("uiFcState-1")) {
GM.xmlHttpRequest({
method: "GET",
url: "http://www.ig.gmodules.com/gadgets/proxy/refresh=31556926&container=ig/http://tangorin.com/kanji/"+document.querySelector(".d-kanji>div>div>span>span").textContent,
onload: function(response) {
var responseHTML = new DOMParser().parseFromString(response.responseText, "text/html");
inject_container.innerHTML = "<br />" + responseHTML.documentElement.querySelector(stroke_container).innerHTML;
}
});
} else {
inject_container.innerHTML = "";
};
});
var config = { attributes: true, subtree: true, childList: true };
observer.observe(target, config);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.