Can now change if words are case sensitive or not
This commit is contained in:
parent
7332ae9d5e
commit
5520cba68d
3 changed files with 118 additions and 2191 deletions
145
constants.json
145
constants.json
|
@ -42,41 +42,114 @@
|
||||||
"https://axiomatic-hair-production.up.railway.app/"
|
"https://axiomatic-hair-production.up.railway.app/"
|
||||||
],
|
],
|
||||||
"highlightedWords": {
|
"highlightedWords": {
|
||||||
"birds": "yellow",
|
"birds": {
|
||||||
"Pissing": "yellow",
|
"color": "yellow"
|
||||||
"Starwalker": "yellow",
|
},
|
||||||
"word highlighting": "yellow",
|
"Pissing": {
|
||||||
"replaceAll": "limegreen",
|
"color": "yellow"
|
||||||
"Godot Engine": "#64B5F6",
|
},
|
||||||
"Javascript": "yellow",
|
"Starwalker": {
|
||||||
"NodeJS": "limegreen",
|
"color": "yellow"
|
||||||
"Violet": "rgb(200, 150, 255)",
|
},
|
||||||
"Purgatory": "rgb(200, 150, 255)",
|
"word highlighting": {
|
||||||
"Asahi": "rgb(255, 175, 175)",
|
"color": "yellow"
|
||||||
"Lunya": "rgb(255, 175, 175)",
|
},
|
||||||
"bisexual": "rgb(214, 2, 112)",
|
"replaceAll": {
|
||||||
"enby": "rgb(252, 244, 52)",
|
"color": "limegreen"
|
||||||
"Youtube": "rgb(255, 0, 0)",
|
},
|
||||||
"Fedi": "rgb(175, 125, 200)",
|
"Godot Engine": {
|
||||||
"Matrix": "limegreen",
|
"color": "#64B5F6"
|
||||||
"Element": "rgb(100, 255, 200)",
|
},
|
||||||
"Codeberg": "rgb(0, 255, 255)",
|
"Javascript": {
|
||||||
"Code": "rgb(150, 175, 255)",
|
"color": "yellow"
|
||||||
"Docker": "blue",
|
},
|
||||||
"Github": "gray",
|
"NodeJS": {
|
||||||
"Steam": "lightgray",
|
"color": "limegreen"
|
||||||
"Univerter": "rgb(200, 175, 255)",
|
},
|
||||||
"Ko-fi": "rgb(255, 150, 150)",
|
"Violet": {
|
||||||
"Revolt": "rgb(255, 50, 50)",
|
"color": "rgb(200, 150, 255)"
|
||||||
"Discord": "rgb(150, 150, 255)",
|
},
|
||||||
"SearXNG": "rgb(100, 100, 255)",
|
"Purgatory": {
|
||||||
"Highlighting": "yellow",
|
"color": "rgb(200, 150, 255)"
|
||||||
"highlighted": "yellow",
|
},
|
||||||
"Forgejo": "orange",
|
"Asahi": {
|
||||||
"HTML": "orange",
|
"color": "rgb(255, 175, 175)"
|
||||||
"CSS": "rgb(50, 200, 255)",
|
},
|
||||||
"Thumbor": "rgb(225, 225, 255)",
|
"Lunya": {
|
||||||
"Spotify": "limegreen",
|
"color": "rgb(255, 175, 175)"
|
||||||
"Ultrakill": "red"
|
},
|
||||||
|
"bisexual": {
|
||||||
|
"color": "rgb(214, 2, 112)"
|
||||||
|
},
|
||||||
|
"enby": {
|
||||||
|
"color": "rgb(252, 244, 52)"
|
||||||
|
},
|
||||||
|
"Youtube": {
|
||||||
|
"color": "rgb(255, 0, 0)"
|
||||||
|
},
|
||||||
|
"Fedi": {
|
||||||
|
"color": "rgb(175, 125, 200)"
|
||||||
|
},
|
||||||
|
"Matrix": {
|
||||||
|
"color": "limegreen"
|
||||||
|
},
|
||||||
|
"Element": {
|
||||||
|
"color": "rgb(100, 255, 200)"
|
||||||
|
},
|
||||||
|
"Codeberg": {
|
||||||
|
"color": "rgb(0, 255, 255)"
|
||||||
|
},
|
||||||
|
"Code": {
|
||||||
|
"color": "rgb(150, 175, 255)"
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"color": "blue"
|
||||||
|
},
|
||||||
|
"Github": {
|
||||||
|
"color": "gray"
|
||||||
|
},
|
||||||
|
"Steam": {
|
||||||
|
"color": "lightgray"
|
||||||
|
},
|
||||||
|
"Univerter": {
|
||||||
|
"color": "rgb(200, 175, 255)"
|
||||||
|
},
|
||||||
|
"Ko-fi": {
|
||||||
|
"color": "rgb(255, 150, 150)"
|
||||||
|
},
|
||||||
|
"Revolt": {
|
||||||
|
"color": "rgb(255, 50, 50)"
|
||||||
|
},
|
||||||
|
"Discord": {
|
||||||
|
"color": "rgb(150, 150, 255)"
|
||||||
|
},
|
||||||
|
"SearXNG": {
|
||||||
|
"color": "rgb(100, 100, 255)"
|
||||||
|
},
|
||||||
|
"Highlighting": {
|
||||||
|
"color": "yellow"
|
||||||
|
},
|
||||||
|
"highlighted": {
|
||||||
|
"color": "yellow"
|
||||||
|
},
|
||||||
|
"Forgejo": {
|
||||||
|
"color": "orange"
|
||||||
|
},
|
||||||
|
"HTML": {
|
||||||
|
"color": "orange"
|
||||||
|
},
|
||||||
|
"CSS": {
|
||||||
|
"color": "rgb(50, 200, 255)"
|
||||||
|
},
|
||||||
|
"Thumbor": {
|
||||||
|
"color": "rgb(225, 225, 255)"
|
||||||
|
},
|
||||||
|
"Spotify": {
|
||||||
|
"color": "limegreen"
|
||||||
|
},
|
||||||
|
"Ultrakill": {
|
||||||
|
"color": "red",
|
||||||
|
"caseInsensitive": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
2153
output.json
2153
output.json
File diff suppressed because it is too large
Load diff
|
@ -142,14 +142,21 @@ function converter(html) {
|
||||||
|
|
||||||
for (let index = 0; index < highTable.length; index++) {
|
for (let index = 0; index < highTable.length; index++) {
|
||||||
var term = highTable[index];
|
var term = highTable[index];
|
||||||
|
var termProps = highlightedWords[term]
|
||||||
|
|
||||||
|
var reg = term
|
||||||
|
if (termProps.caseInsensitive) {
|
||||||
|
reg = new RegExp(`(${term})`, "gi")
|
||||||
|
}
|
||||||
|
|
||||||
element.content = element.content.replaceAll(`{${term}}`, "TEMPORARY_REPLACE")
|
element.content = element.content.replaceAll(`{${term}}`, "TEMPORARY_REPLACE")
|
||||||
element.content = element.content.replaceAll(term, "{TERM" + index + "}")
|
element.content = element.content.replaceAll(reg, "{TERM" + index + "}")
|
||||||
element.content = element.content.replaceAll("TEMPORARY_REPLACE", `${term}`)
|
element.content = element.content.replaceAll("TEMPORARY_REPLACE", `${term}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let index = 0; index < highTable.length; index++) {
|
for (let index = 0; index < highTable.length; index++) {
|
||||||
var termKey = "{TERM" + index + "}"
|
var termKey = "{TERM" + index + "}"
|
||||||
|
var termProps = highlightedWords[highTable[index]]
|
||||||
while (element.content.includes(termKey)) {
|
while (element.content.includes(termKey)) {
|
||||||
var termIndex = element.content.indexOf(termKey)
|
var termIndex = element.content.indexOf(termKey)
|
||||||
|
|
||||||
|
@ -164,7 +171,7 @@ function converter(html) {
|
||||||
var spanStart = element.content.substring(0, termIndex).lastIndexOf(" ")
|
var spanStart = element.content.substring(0, termIndex).lastIndexOf(" ")
|
||||||
var startContent = element.content.substring(spanStart, termIndex)
|
var startContent = element.content.substring(spanStart, termIndex)
|
||||||
|
|
||||||
var replacement = `<span style="color: ${highlightedWords[highTable[index]]}">${startContent + highTable[index] + endContent}</span>`
|
var replacement = `<span style="color: ${termProps.color}">${startContent + highTable[index] + endContent}</span>`
|
||||||
|
|
||||||
element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd)
|
element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue