mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
fix(eslint): make eslint happy
This commit is contained in:
parent
a006bdaef2
commit
9db33360a9
@ -18,17 +18,6 @@ const processAcgLinks = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const isTextInsideLink = (html: string, position: number): boolean => {
|
|
||||||
const beforeText = html.substring(0, position)
|
|
||||||
const lastOpenTag = beforeText.lastIndexOf('<a ')
|
|
||||||
if (lastOpenTag === -1) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const lastCloseTag = beforeText.lastIndexOf('</a>')
|
|
||||||
return lastOpenTag > lastCloseTag
|
|
||||||
}
|
|
||||||
|
|
||||||
const processDescLinks = () => {
|
const processDescLinks = () => {
|
||||||
const descContainer = document.querySelector('.desc-info-text')
|
const descContainer = document.querySelector('.desc-info-text')
|
||||||
if (!descContainer) {
|
if (!descContainer) {
|
||||||
@ -45,9 +34,10 @@ const processDescLinks = () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const textNodes: Text[] = []
|
const textNodes: Text[] = []
|
||||||
let currentNode: Node | null
|
let currentNode: Node | null = walker.nextNode()
|
||||||
while ((currentNode = walker.nextNode())) {
|
while (currentNode !== null) {
|
||||||
textNodes.push(currentNode as Text)
|
textNodes.push(currentNode as Text)
|
||||||
|
currentNode = walker.nextNode()
|
||||||
}
|
}
|
||||||
textNodes.forEach(textNode => {
|
textNodes.forEach(textNode => {
|
||||||
const frag = document.createDocumentFragment()
|
const frag = document.createDocumentFragment()
|
||||||
@ -55,7 +45,8 @@ const processDescLinks = () => {
|
|||||||
let lastIndex = 0
|
let lastIndex = 0
|
||||||
let match: RegExpExecArray | null
|
let match: RegExpExecArray | null
|
||||||
webRegex.lastIndex = 0
|
webRegex.lastIndex = 0
|
||||||
while ((match = webRegex.exec(text)) !== null) {
|
match = webRegex.exec(text)
|
||||||
|
while (match !== null) {
|
||||||
const start = match.index
|
const start = match.index
|
||||||
if (lastIndex < start) {
|
if (lastIndex < start) {
|
||||||
frag.appendChild(document.createTextNode(text.slice(lastIndex, start)))
|
frag.appendChild(document.createTextNode(text.slice(lastIndex, start)))
|
||||||
@ -68,6 +59,7 @@ const processDescLinks = () => {
|
|||||||
a.textContent = urlText
|
a.textContent = urlText
|
||||||
frag.appendChild(a)
|
frag.appendChild(a)
|
||||||
lastIndex = start + urlText.length
|
lastIndex = start + urlText.length
|
||||||
|
match = webRegex.exec(text)
|
||||||
}
|
}
|
||||||
if (lastIndex < text.length) {
|
if (lastIndex < text.length) {
|
||||||
frag.appendChild(document.createTextNode(text.slice(lastIndex)))
|
frag.appendChild(document.createTextNode(text.slice(lastIndex)))
|
||||||
@ -102,6 +94,7 @@ const normalizeNicoDescLinks = () => {
|
|||||||
a1.replaceWith(newA)
|
a1.replaceWith(newA)
|
||||||
a2.remove()
|
a2.remove()
|
||||||
console.log(`Merged Nico link: ${text2}`)
|
console.log(`Merged Nico link: ${text2}`)
|
||||||
|
// skip the next element
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user