Skip to content

Instantly share code, notes, and snippets.

@hemmer
Created September 27, 2020 16:53
Show Gist options
  • Save hemmer/8c19110d55e1f44c8246769c01544890 to your computer and use it in GitHub Desktop.
Save hemmer/8c19110d55e1f44c8246769c01544890 to your computer and use it in GitHub Desktop.
Adds links to wanikani vocab pages from the button on jisho
// ==UserScript==
// @name Add proper Wanikani links to Jisho
// @version 1
// @grant none
// @include https://jisho.org*
// ==/UserScript==
var aTags = document.getElementsByTagName("a");
var searchText = "wanikani";
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].textContent.substring(0, 8).toLowerCase() == searchText) {
var readingDiv = aTags[i].parentElement.parentElement.parentElement.getElementsByTagName("div")[0];
var textEl = readingDiv.getElementsByTagName("div")[0].getElementsByTagName("span");
var fullForm;
for (var j = 0; j < textEl.length; j++) {
if (textEl[j].classList == "text") {
fullForm = textEl[j].textContent.trim();
}
}
aTags[i].href = "https://www.wanikani.com/vocabulary/" + fullForm;
}
}
@hemmer
Copy link
Author

hemmer commented Sep 27, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment