Compare commits
7 commits
developmen
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
303879145b | ||
|
18d679476e | ||
![]() |
8df65ea893 | ||
![]() |
64634405be | ||
![]() |
1cb190d2e8 | ||
![]() |
c8dd677f4a | ||
![]() |
60a2943d2d |
|
@ -8,6 +8,8 @@ This is a chrome extension that automatically removes furigana from websites bas
|
||||||
## Installation
|
## Installation
|
||||||
[Download it from the Chrome Web Store](https://chrome.google.com/webstore/detail/furikani/lbjenjfljjnlkbdfbgmgcnkfnddaeccl)
|
[Download it from the Chrome Web Store](https://chrome.google.com/webstore/detail/furikani/lbjenjfljjnlkbdfbgmgcnkfnddaeccl)
|
||||||
|
|
||||||
|
[Download it from the Firefox Add-On Store](https://addons.mozilla.org/en-US/firefox/addon/furikani/)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
|
@ -10,4 +10,11 @@
|
||||||
## v0.6.3
|
## v0.6.3
|
||||||
* Startup sync check is now more consistent
|
* Startup sync check is now more consistent
|
||||||
* Level number updates in realtime after sync
|
* Level number updates in realtime after sync
|
||||||
* Fixed bug where internal Kanji list would get reset on sync
|
* Fixed bug where internal Kanji list would get reset on sync
|
||||||
|
|
||||||
|
# v0.7
|
||||||
|
* FuriKani now supports Firefox!
|
||||||
|
* Fixed potential innerHTML risks
|
||||||
|
|
||||||
|
## v0.7.1
|
||||||
|
* Add support for non-static websites
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "FuriKani",
|
"name": "FuriKani",
|
||||||
"description": "Removes furigana on websites based on your WaniKani level",
|
"description": "Removes furigana on websites based on your WaniKani level",
|
||||||
"version": "0.6.3",
|
"version": "0.7",
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "res/icon16.png",
|
"16": "res/icon16.png",
|
||||||
"48": "res/icon48.png",
|
"48": "res/icon48.png",
|
||||||
|
@ -21,4 +21,4 @@
|
||||||
"scripts": ["src/background.js"]
|
"scripts": ["src/background.js"]
|
||||||
},
|
},
|
||||||
"permissions": ["storage"]
|
"permissions": ["storage"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,35 @@ var kanjiStyleSheet = document.createElement("style")
|
||||||
document.head.appendChild(vocabStyleSheet)
|
document.head.appendChild(vocabStyleSheet)
|
||||||
document.head.appendChild(kanjiStyleSheet)
|
document.head.appendChild(kanjiStyleSheet)
|
||||||
|
|
||||||
|
function handleRubyTag(tag, vocabulary, kanji) {
|
||||||
|
// Copy the ruby element into a new ruby element so we can modify it
|
||||||
|
// without modifying the website
|
||||||
|
var ruby = document.createElement("ruby")
|
||||||
|
ruby.innerHTML = tag.innerHTML;
|
||||||
|
|
||||||
|
// Remove all tags (except for <rb>, <span>)
|
||||||
|
while(ruby.lastElementChild)
|
||||||
|
{
|
||||||
|
if(ruby.lastElementChild.tagName.toLowerCase() === "rb" ||
|
||||||
|
ruby.lastElementChild.tagName.toLowerCase() === "span")
|
||||||
|
{
|
||||||
|
ruby.innerHTML = ruby.lastElementChild.innerHTML
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
ruby.removeChild(ruby.lastElementChild)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the contents of the <ruby> tag are in the word list, tag the <rt> tag
|
||||||
|
// with the correct class
|
||||||
|
var rtTag = tag.getElementsByTagName("rt").item(0)
|
||||||
|
if(vocabulary.includes(ruby.innerText))
|
||||||
|
rtTag.classList.add("furikani-vocabulary")
|
||||||
|
if(kanji.includes(ruby.innerText))
|
||||||
|
rtTag.classList.add("furikani-kanji")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get stored word list from chrome storage
|
// Get stored word list from chrome storage
|
||||||
chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel", "enabled", "enabledVocab", "enabledKanji"], (data) => {
|
chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel", "enabled", "enabledVocab", "enabledKanji"], (data) => {
|
||||||
// The users level is not valid, e.g. it exceeds the maximum allowed level
|
// The users level is not valid, e.g. it exceeds the maximum allowed level
|
||||||
|
@ -39,37 +68,19 @@ chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel", "enabled", "e
|
||||||
const vocabulary = data.vocabulary
|
const vocabulary = data.vocabulary
|
||||||
const kanji = data.kanji
|
const kanji = data.kanji
|
||||||
|
|
||||||
// Fetch all <ruby> tags on the website
|
let observer = new MutationObserver((mutations) => {
|
||||||
var rubyTags = document.body.getElementsByTagName("ruby")
|
mutations.forEach((mutation) => {
|
||||||
|
mutation.addedNodes.forEach((node, _key, _parent) => {
|
||||||
|
if (node.tagName?.toLowerCase() !== "ruby") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(let tag in rubyTags)
|
handleRubyTag(node, vocabulary, kanji)
|
||||||
{
|
})
|
||||||
// Copy the ruby element into a new ruby element so we can modify it
|
});
|
||||||
// without modifying the website
|
})
|
||||||
var ruby = document.createElement("ruby")
|
|
||||||
ruby.innerHTML = rubyTags.item(tag).innerHTML
|
|
||||||
|
|
||||||
// Remove all tags (except for <rb>, <span>)
|
observer.observe(document.documentElement, { subtree: true, childList: true });
|
||||||
while(ruby.lastElementChild)
|
|
||||||
{
|
|
||||||
if(ruby.lastElementChild.tagName.toLowerCase() === "rb" ||
|
|
||||||
ruby.lastElementChild.tagName.toLowerCase() === "span")
|
|
||||||
{
|
|
||||||
ruby.innerHTML = ruby.lastElementChild.innerHTML
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
ruby.removeChild(ruby.lastElementChild)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the contents of the <ruby> tag are in the word list, tag the <rt> tag
|
|
||||||
// with the correct class
|
|
||||||
var rtTag = rubyTags.item(tag).getElementsByTagName("rt").item(0)
|
|
||||||
if(vocabulary.includes(ruby.innerText))
|
|
||||||
rtTag.classList.add("furikani-vocabulary")
|
|
||||||
if(kanji.includes(ruby.innerText))
|
|
||||||
rtTag.classList.add("furikani-kanji")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
||||||
|
@ -96,4 +107,4 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1>FuriKani</h1>
|
<h1>FuriKani</h1>
|
||||||
<h2>v0.6.3</h2>
|
<h2>v0.7</h2>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div id="token-area">
|
<div id="token-area">
|
||||||
|
@ -53,10 +53,10 @@
|
||||||
<footer>
|
<footer>
|
||||||
<span id="level-text">Using WaniKani Level <span id="level"></span></span>
|
<span id="level-text">Using WaniKani Level <span id="level"></span></span>
|
||||||
|
|
||||||
<span id="author" >Made by <a target="_blank" href="https://github.com/Lauchmelder23">Lauchmelder</a></span>
|
<span id="author" >Made by <a target="_blank" href="https://repos.einweckglas.com/lauchmelder">Lauchmelder</a></span>
|
||||||
<a id="source" target="_blank" href="https://github.com/Lauchmelder23/FuriKani">Source Code</a>
|
<a id="source" target="_blank" href="https://repos.einweckglas.com/lauchmelder/FuriKani">Source Code</a>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="popup.js"></script>
|
<script src="popup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue