Skip to content

Commit 5a3c4dd

Browse files
committed
chore: improve for github (#7)
1 parent deceb06 commit 5a3c4dd

File tree

1 file changed

+6
-11
lines changed
  • src/content-script/site-adapters/github

1 file changed

+6
-11
lines changed

src/content-script/site-adapters/github/index.mjs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,17 @@ const getPatchData = async (patchUrl) => {
1919
export default {
2020
init: async (hostname, userConfig, getInput, mountComponent) => {
2121
try {
22-
const targetNode = document.querySelector('body')
23-
const observer = new MutationObserver(async (records) => {
24-
if (
25-
records.some(
26-
(record) =>
27-
record.type === 'childList' &&
28-
[...record.addedNodes].some((node) => node.classList.contains('page-responsive')),
29-
)
30-
) {
22+
let oldUrl = location.href
23+
const checkUrlChange = async () => {
24+
if (location.href !== oldUrl) {
25+
oldUrl = location.href
3126
const patchUrl = await getPatchUrl()
3227
if (patchUrl) {
3328
mountComponent(config.github, userConfig)
3429
}
3530
}
36-
})
37-
observer.observe(targetNode, { childList: true })
31+
}
32+
window.setInterval(checkUrlChange, 500)
3833
} catch (e) {
3934
/* empty */
4035
}

0 commit comments

Comments
 (0)