mirror of
https://github.com/cupcakearmy/ora.git
synced 2024-12-22 16:16:23 +00:00
wrap in try and update more often
This commit is contained in:
parent
f72d88ddc1
commit
ef2a02577e
@ -5,32 +5,33 @@ import { insertLog, normalizeTimestamp } from '../shared/db'
|
|||||||
|
|
||||||
browser.browserAction.onClicked.addListener(() => browser.tabs.create({ url: dashboard, active: true }))
|
browser.browserAction.onClicked.addListener(() => browser.tabs.create({ url: dashboard, active: true }))
|
||||||
|
|
||||||
const frequency = 3000
|
const frequency = 1000
|
||||||
|
|
||||||
async function getAllTabs() {
|
async function getAllTabs() {
|
||||||
console.log('Checking...')
|
try {
|
||||||
const tabs = await browser.tabs.query({})
|
const tabs = await browser.tabs.query({})
|
||||||
const windows = await browser.windows.getAll()
|
const windows = await browser.windows.getAll()
|
||||||
const active = tabs
|
const active = tabs
|
||||||
.filter((tab) => {
|
.filter((tab) => {
|
||||||
const window = windows.find((window) => window.id === tab.windowId)
|
const window = windows.find((window) => window.id === tab.windowId)
|
||||||
return tab.active && window.focused
|
return tab.active && window.focused
|
||||||
})
|
})
|
||||||
.map(({ id, title, url }) => {
|
.map(({ id, title, url }) => {
|
||||||
const { host } = new URL(url)
|
const { host } = new URL(url)
|
||||||
return { id, title, host }
|
return { id, title, host }
|
||||||
})
|
})
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
active.map(({ host }) => {
|
active.map(({ host }) => {
|
||||||
if (host)
|
if (host)
|
||||||
return insertLog({
|
return insertLog({
|
||||||
timestamp: normalizeTimestamp(new Date()),
|
timestamp: normalizeTimestamp(new Date()),
|
||||||
host,
|
host,
|
||||||
seconds: (frequency / 1000) | 0,
|
seconds: (frequency / 1000) | 0,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user