Created
September 27, 2020 16:53
-
-
Save hemmer/8c19110d55e1f44c8246769c01544890 to your computer and use it in GitHub Desktop.
Adds links to wanikani vocab pages from the button on jisho
This file contains hidden or 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 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; | |
} | |
} |
Author
hemmer
commented
Sep 27, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment