MCPcopy
hub / github.com/ChinaGodMan/UserScripts / observeUrlChanges

Function observeUrlChanges

github-to-deepwiki/github-to-deepwiki.user.js:430–443  ·  view source on GitHub ↗
(callback, delay = 10)

Source from the content-addressed store, hash-verified

428}
429
430function observeUrlChanges(callback, delay = 10) {
431 let lastUrl = location.href
432 const observer = new MutationObserver(() => {
433 const url = location.href
434 if (url !== lastUrl) {
435 lastUrl = url
436 setTimeout(() => {
437 callback()
438 }, delay)
439 }
440 })
441 observer.observe(document, { subtree: true, childList: true })
442 return observer
443}
444observeUrlChanges(checkAndInsert)
445checkAndInsert()

Callers 1

Calls 1

callbackFunction · 0.85

Tested by

no test coverage detected