add initial cleanse of ruby tags on page load
This commit is contained in:
parent
303879145b
commit
597a1d9d20
3 changed files with 12 additions and 1 deletions
|
@ -18,3 +18,6 @@
|
|||
|
||||
## v0.7.1
|
||||
* Add support for non-static websites
|
||||
|
||||
## v0.7.2
|
||||
* Explicitly handle ruby tags on initial page load
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue