From 597a1d9d20b4339e4ed59e6efd105aa1934b350c Mon Sep 17 00:00:00 2001 From: lauchmelder Date: Fri, 18 Apr 2025 17:30:36 +0200 Subject: [PATCH] add initial cleanse of ruby tags on page load --- VERSIONS.md | 3 +++ manifest.json | 2 +- src/content.js | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/VERSIONS.md b/VERSIONS.md index c2d9511..b4e95f3 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -18,3 +18,6 @@ ## v0.7.1 * Add support for non-static websites + +## v0.7.2 + * Explicitly handle ruby tags on initial page load diff --git a/manifest.json b/manifest.json index 9efc9d9..3223517 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "FuriKani", "description": "Removes furigana on websites based on your WaniKani level", - "version": "0.7", + "version": "0.7.2", "icons": { "16": "res/icon16.png", "48": "res/icon48.png", diff --git a/src/content.js b/src/content.js index d5a01b3..73a020f 100644 --- a/src/content.js +++ b/src/content.js @@ -47,6 +47,12 @@ function handleRubyTag(tag, vocabulary, kanji) { rtTag.classList.add("furikani-kanji") } +function removeExistingTags(vocabulary, kanji) { + let nodes = document.querySelectorAll("ruby") + nodes.forEach((node, _key, _parent) => { + handleRubyTag(node, vocabulary, kanji) + }); +}; // Get stored word list from chrome storage chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel", "enabled", "enabledVocab", "enabledKanji"], (data) => { @@ -68,6 +74,8 @@ chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel", "enabled", "e const vocabulary = data.vocabulary const kanji = data.kanji + removeExistingTags(vocabulary, kanji) + let observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node, _key, _parent) => {