Skip to content

Commit

Permalink
feat: replace title / X to / Twitter
Browse files Browse the repository at this point in the history
closes #4
  • Loading branch information
pionxzh committed Jul 28, 2023
1 parent d42894e commit 6634b8e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/userscript/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function main() {

replaceLinkRel()
replaceMetaName()
replaceTitle()
})
}

Expand Down Expand Up @@ -123,4 +124,17 @@ function replaceMetaName() {
})
}

function replaceTitle() {
const title = document.querySelector<HTMLTitleElement>('title')
if (!title) return
const sync = () => {
if (document.title.endsWith(' / X')) {
document.title = `${document.title.slice(0, -1)}Twitter`
}
}
sync()
window.addEventListener('visibilitychange', sync)
new MutationObserver(sync).observe(title, mutationObserverOptions)
}

main()

0 comments on commit 6634b8e

Please sign in to comment.