Last active
December 18, 2021 02:21
-
-
Save fernap3/4203b036e44359463d6d4e749e74ed01 to your computer and use it in GitHub Desktop.
Hide ruby text (eg. furigana) on a web page. Mouseover to reveal.
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
document.addEventListener("mouseover", (evt) => | |
{ | |
const ruby = evt.target; | |
if (ruby.tagName !== "RUBY") | |
return; | |
for (const rt of [...ruby.querySelectorAll("rt")]) | |
rt.style.opacity = ""; | |
}); | |
document.addEventListener("mouseout", (evt) => | |
{ | |
const ruby = evt.target; | |
if (ruby.tagName !== "RUBY") | |
return; | |
for (const rt of [...ruby.querySelectorAll("rt")]) | |
rt.style.opacity = "0"; | |
}); | |
const allRt = document.querySelectorAll("rt"); | |
for (const rt of allRt) | |
{ | |
rt.style.opacity = "0"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can be used as a bookmarklet (tested in Chrome and Safari). Just prepend the script text with
javascript:
.