2023-09-26 20:20:43 +00:00
|
|
|
const SITE_NAME = document.querySelector("[name='application-name']").content
|
2023-09-26 20:05:39 +00:00
|
|
|
const icon = document.querySelector("link[rel~='icon']")
|
|
|
|
const page_title = document.getElementsByTagName('title')[0].innerHTML
|
|
|
|
|
|
|
|
let notifs = 0
|
|
|
|
let focused = true
|
|
|
|
let alert = true;
|
|
|
|
|
|
|
|
addEventListener('blur', function(){
|
|
|
|
focused = false
|
|
|
|
})
|
|
|
|
addEventListener('focus', function(){
|
|
|
|
focused = true
|
|
|
|
})
|
|
|
|
|
|
|
|
function flash(){
|
|
|
|
let title = document.getElementsByTagName('title')[0]
|
|
|
|
if (notifs >= 1 && !focused){
|
|
|
|
title.innerHTML = `[+${notifs}] ${page_title}`
|
|
|
|
if (alert) {
|
2023-09-26 20:09:34 +00:00
|
|
|
icon.href = `${SITE_FULL_IMAGES}/i/${SITE_NAME}/alert.ico?v=3009`
|
2023-09-26 20:05:39 +00:00
|
|
|
alert = false
|
|
|
|
}
|
|
|
|
else {
|
2023-09-26 20:09:34 +00:00
|
|
|
icon.href = `${SITE_FULL_IMAGES}/i/${SITE_NAME}/icon.webp?x=6`
|
2023-09-26 20:05:39 +00:00
|
|
|
alert = true
|
|
|
|
}
|
|
|
|
setTimeout(flash, 500)
|
|
|
|
}
|
|
|
|
else {
|
2023-09-26 20:09:34 +00:00
|
|
|
icon.href = `${SITE_FULL_IMAGES}/i/${SITE_NAME}/icon.webp?x=6`
|
2023-09-26 20:05:39 +00:00
|
|
|
notifs = 0
|
|
|
|
title.innerHTML = page_title
|
|
|
|
}
|
|
|
|
}
|