tweaks for the notification message

This commit is contained in:
kapypara 2023-12-16 20:39:46 +03:00
parent 85a1bb76b5
commit e327e6acc9
1 changed files with 21 additions and 23 deletions

View File

@ -82,7 +82,7 @@ function getItem(id) {
try {
return fetch(url).then(response => response.json().then(obj => obj))
} catch (e) {
console.log(`[getItem]: failed to fetch item ${id}`)
console.log(`[getItem] failed to fetch item ${id}`)
return
}
}
@ -91,13 +91,13 @@ function getItem(id) {
function makeItemListing(itemObj) {
if (itemObj === null || itemObj === undefined) {
console.log(`[makeItemListing]: null or undefined object`)
console.log(`[makeItemListing] null or undefined object`)
clearInterval(loader_id)
return
}
if (itemObj.deleted || itemObj.dead || itemObj.title == "[deleted]") {
console.log(`[makeItemListing]: bad item: ${itemObj.id}`)
console.log(`[makeItemListing] bad item: ${itemObj.id}`)
return
}
@ -123,7 +123,7 @@ function makeItemListing(itemObj) {
if (itemObj.type != itemType.job) {
subtitle += ` | ${comments} comments`
} else {
console.log(`[makeItemListing]: job item ${title}`)
console.log(`[makeItemListing] job item ${title}`)
}
const element_string =`
@ -416,7 +416,7 @@ async function notify(count) {
return
}
new Notification("Clone Wars", { body: `${count} new Post`})
new Notification("Clone Wars", { body: "new Posts"})
}
async function loadFresh() {
@ -435,7 +435,7 @@ async function loadFresh() {
return
}
console.log(`[loadFresh]: new items ${newMax - endItem}`)
console.log(`[loadFresh] new items ${newMax - endItem}`)
let count = 0
let intervalId = setInterval(async () => {
@ -473,27 +473,25 @@ if (newMode) {
if (!isQuery) {
setInterval(() => {
Array.from(pageItemBox.getElementsByTagName('a')).map(c => {
setInterval(() => Array.from(pageItemBox.getElementsByTagName('a')).map(c => {
if (!c.time) {
return
}
if (!c.time) {
return
}
const sub = c.getElementsByClassName('subtitle')[0]
const sub = c.getElementsByClassName('subtitle')[0]
const date = timeSince(c.time)
const points = c.points
const author = c.author
const comments = c.comments
const date = timeSince(c.time)
const points = c.points
const author = c.author
const comments = c.comments
let subtitle = `${points} points by ${author} ${date} ago`
let subtitle = `${points} points by ${author} ${date} ago`
if (comments !== undefined) {
subtitle += ` | ${comments} comments`
}
if (comments !== undefined) {
subtitle += ` | ${comments} comments`
}
sub.innerHTML = subtitle
})
}, 1e3)
sub.innerHTML = subtitle
}), 1e3)
}