Skip to content

Commit 5bace60

Browse files
committed
fix: caching issue of mobile web browsers
1 parent 63ac5f1 commit 5bace60

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sources/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
8888
})
8989
}
9090

91-
window.addEventListener('SpaRendered', async () => {
91+
const Handler = async () => {
9292
let HTMLEle = Sort.CollectDataVAttributes(document)
9393
const { Result, TotalKeys, WorkerCount, HardwareConcurrency } = await Sort.RankCountsWithWorkersParallel(HTMLEle)
9494
let TargetedAttrsDOMs: HTMLElement[] = []
@@ -105,11 +105,14 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
105105
TargetedAttrsDOMs = TargetedAttrsDOMs.filter(El => [...El.querySelectorAll('*')].some(Child => Child instanceof HTMLElement && getComputedStyle(Child, '::after').getPropertyValue('content').includes(':') && Child.getBoundingClientRect().right - Child.getBoundingClientRect().left > 100) === false)
106106
console.debug(`[${UserscriptName}]`, TargetedAttrsDOMs)
107107
TargetedAttrsDOMs.forEach(El => {
108-
setTimeout(() => {
108+
setInterval(() => {
109109
El.setAttribute('style', 'display: none !important; visibility: hidden !important;')
110110
}, 250)
111111
})
112-
})
112+
}
113+
114+
window.addEventListener('SpaRendered', () => setTimeout(Handler, 2500))
115+
window.addEventListener('SpaRendered', Handler)
113116
}
114117

115118
RunNamuLinkUserscript(Win)

0 commit comments

Comments
 (0)