Skip to content

Instantly share code, notes, and snippets.

@dougbacelar
Last active April 23, 2024 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dougbacelar/481a95dfea33677bc04e74cde6eebea2 to your computer and use it in GitHub Desktop.
Save dougbacelar/481a95dfea33677bc04e74cde6eebea2 to your computer and use it in GitHub Desktop.
more convenient way to mark easy words as 'Never Forget' when starting to study on jpdb. https://jpdb.io/deck?id=3&sort_by=by-frequency-global&show_only=new
const targetNode = document.querySelector("div.vocabulary-list");
const config = { attributes: false, childList: true, subtree: true };
const handleMutations = function (mutationsList) {
for (const mutation of mutationsList) {
if (mutation.type === "childList") {
if (mutation.removedNodes.length > 0) {
console.log("appending buttons");
appendButtons();
removeFurigana();
}
}
}
};
const observer = new MutationObserver(handleMutations);
observer.observe(targetNode, config);
const appendButtons = () =>
[
...document.querySelectorAll('form[action="/deck/never-forget/add"]'),
].forEach((elem) =>
elem?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.append(
elem,
),
);
appendButtons();
const removeFurigana = () =>
document.querySelectorAll("ruby rt").forEach((elem) => elem.remove());
removeFurigana();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment