Skip to content

Instantly share code, notes, and snippets.

@fernap3
Last active December 18, 2021 02:21
Show Gist options
  • Save fernap3/4203b036e44359463d6d4e749e74ed01 to your computer and use it in GitHub Desktop.
Save fernap3/4203b036e44359463d6d4e749e74ed01 to your computer and use it in GitHub Desktop.
Hide ruby text (eg. furigana) on a web page. Mouseover to reveal.
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";
}
@fernap3
Copy link
Author

fernap3 commented Dec 18, 2021

Can be used as a bookmarklet (tested in Chrome and Safari). Just prepend the script text with javascript:.

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