saahildcom/src/scripts/title.ts
2024-06-16 00:57:13 -04:00

20 lines
No EOL
529 B
TypeScript

let title0: null | string = null
let interId: any = null
export function runTitle() {
if(interId) clearInterval(interId)
interId = setInterval(() => {
if(document.title !== 'Come Back :(') {
title0 = document.title
}
if (document.hasFocus()) {
document.title = title0 || "Saahild.com"
} else {
document.title = 'Come Back :('
}
}, 200)
}
export function stopTitle() {
if(!interId) return false;
return clearInterval(interId)
}