2025-04-24 23:14:06 +00:00
|
|
|
async function api(url, key, endpoint) {
|
|
|
|
const response = await fetch(`${url}/v1/${endpoint}`, {
|
|
|
|
headers: { "X-Auth-Token": key },
|
|
|
|
})
|
|
|
|
return response.json()
|
|
|
|
}
|
|
|
|
|
|
|
|
window.onload = async function run() {
|
|
|
|
const params = new URLSearchParams(window.location.search)
|
|
|
|
const url = `https://${params.get("url")}`
|
|
|
|
const key = params.get("key")
|
|
|
|
|
|
|
|
const link = document.createElement("a")
|
|
|
|
link.href = url
|
|
|
|
document.body.appendChild(link)
|
|
|
|
|
|
|
|
const counters = await api(url, key, 'feeds/counters')
|
|
|
|
const unreads = Object.entries(counters.unreads).sort(([,a],[,b]) => b-a)
|
|
|
|
|
|
|
|
for (const [id, count] of unreads) {
|
|
|
|
const icon = await api(url, key, `feeds/${id}/icon`)
|
|
|
|
const container = document.createElement("div")
|
2025-07-08 23:27:27 +00:00
|
|
|
const feedLink = document.createElement("a")
|
|
|
|
feedLink.href = `${url}/feed/${id}/entries`
|
2025-04-24 23:14:06 +00:00
|
|
|
const img = document.createElement("img")
|
|
|
|
const num = document.createElement("b")
|
|
|
|
img.src = `data:${icon.data}`
|
2025-04-27 13:21:05 +00:00
|
|
|
if (count < 10) { num.textContent = count }
|
|
|
|
else { num.textContent = String.fromCharCode(count + 55) }
|
2025-07-08 23:27:27 +00:00
|
|
|
feedLink.appendChild(img)
|
|
|
|
feedLink.appendChild(num)
|
|
|
|
container.appendChild(feedLink)
|
2025-04-24 23:14:06 +00:00
|
|
|
link.appendChild(container)
|
|
|
|
}
|
2025-04-27 13:21:05 +00:00
|
|
|
}
|