replaced innerHTML with innerText

This commit is contained in:
Lauchmelder 2022-04-01 14:07:30 +02:00
parent fbf68d06d5
commit 4d67d66d8e
No known key found for this signature in database
GPG key ID: C2403C69D78F011D
2 changed files with 19 additions and 19 deletions

View file

@ -30,10 +30,10 @@ chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel", "enabled", "e
if(data.enabled) if(data.enabled)
{ {
if(data.enabledVocab) if(data.enabledVocab)
vocabStyleSheet.innerHTML = vocabStyle vocabStyleSheet.innerText = vocabStyle
if(data.enabledKanji) if(data.enabledKanji)
kanjiStyleSheet.innerHTML = kanjiStyle kanjiStyleSheet.innerText = kanjiStyle
} }
const vocabulary = data.vocabulary const vocabulary = data.vocabulary
@ -81,15 +81,15 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
// If everything is disabled, disable all stylsheets // If everything is disabled, disable all stylsheets
if(!data.enabled) if(!data.enabled)
{ {
vocabStyleSheet.innerHTML = "" vocabStyleSheet.innerText = ""
kanjiStyleSheet.innerHTML = "" kanjiStyleSheet.innerText = ""
return return
} }
// Otherwise set the kanji and vocab stylesheets depending on their settings // Otherwise set the kanji and vocab stylesheets depending on their settings
vocabStyleSheet.innerHTML = data.enabledVocab ? vocabStyle : "" vocabStyleSheet.innerText = data.enabledVocab ? vocabStyle : ""
kanjiStyleSheet.innerHTML = data.enabledKanji ? kanjiStyle : "" kanjiStyleSheet.innerText = data.enabledKanji ? kanjiStyle : ""
sendResponse(true) sendResponse(true)
}) })

View file

@ -12,31 +12,31 @@ chrome.storage.local.get(["level", "token", "enabled", "enabledVocab", "enabledK
// If no token is set, display exlamation mark and checkmark button // If no token is set, display exlamation mark and checkmark button
if(data.token === undefined) if(data.token === undefined)
{ {
statusField.innerHTML = String.fromCodePoint(0x2757) statusField.innerText = String.fromCodePoint(0x2757)
submitButton.innerHTML = String.fromCodePoint(0x2705) submitButton.innerText = String.fromCodePoint(0x2705)
submitButton.classList.add("no-token") submitButton.classList.add("no-token")
} }
else // else display checkmark and reload button else // else display checkmark and reload button
{ {
statusField.innerHTML = String.fromCodePoint(0x2705) statusField.innerText = String.fromCodePoint(0x2705)
submitButton.innerHTML = String.fromCodePoint(0x1F501) submitButton.innerText = String.fromCodePoint(0x1F501)
} }
// Display the users current WaniKani level // Display the users current WaniKani level
const levelSpan = document.getElementById("level") const levelSpan = document.getElementById("level")
levelSpan.innerHTML = data.level levelSpan.innerText = data.level
// If the input field contains text that is not the current token, turn the // If the input field contains text that is not the current token, turn the
// button into a checkmark (else turn it into a repeat button) // button into a checkmark (else turn it into a repeat button)
inputField.addEventListener("input", () => { inputField.addEventListener("input", () => {
if(inputField.value !== "" && inputField.value !== data.token) if(inputField.value !== "" && inputField.value !== data.token)
{ {
submitButton.innerHTML = String.fromCodePoint(0x2705) submitButton.innerText = String.fromCodePoint(0x2705)
submitButton.classList.add("new-token") submitButton.classList.add("new-token")
} }
else else
{ {
submitButton.innerHTML = String.fromCodePoint(0x1F501) submitButton.innerText = String.fromCodePoint(0x1F501)
submitButton.classList.remove("new-token") submitButton.classList.remove("new-token")
} }
}) })
@ -60,25 +60,25 @@ submitButton.addEventListener( "click", () => {
if(submitButton.classList.contains("no-token")) if(submitButton.classList.contains("no-token"))
return return
statusField.innerHTML = String.fromCodePoint(0x23F1) statusField.innerText = String.fromCodePoint(0x23F1)
// Sync with wanikani // Sync with wanikani
chrome.runtime.sendMessage("", {type: "sync"}, response => { chrome.runtime.sendMessage("", {type: "sync"}, response => {
if(response.success) if(response.success)
{ {
statusField.innerHTML = String.fromCodePoint(0x2705) statusField.innerText = String.fromCodePoint(0x2705)
errorField.innerHTML = "" errorField.innerText = ""
// Update the users current WaniKani level // Update the users current WaniKani level
chrome.storage.local.get("level", (data) => { chrome.storage.local.get("level", (data) => {
const levelSpan = document.getElementById("level") const levelSpan = document.getElementById("level")
levelSpan.innerHTML = data.level levelSpan.innerText = data.level
}) })
} }
else else
{ {
statusField.innerHTML = String.fromCodePoint(0x2757) statusField.innerText = String.fromCodePoint(0x2757)
errorField.innerHTML = response.error errorField.innerText = response.error
} }
}) })
}) })