-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
33 lines (30 loc) · 969 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fetchPub = document.getElementById('fetch')
const table = document.getElementById('content')
const getPubs = () => {
chrome.runtime.sendMessage('fetchPubs', ({ publications }) => {
for (const pub of publications) {
const row = table.insertRow()
const pubDate = row.insertCell()
const pubDateText = document.createTextNode(
new Date(pub.date).toLocaleString()
)
pubDate.appendChild(pubDateText)
const pubLink = document.createElement('a')
pubLink.href = pub.url
pubLink.target = '_blank'
const title = row.insertCell()
const titleText = document.createTextNode(pub.title)
pubLink.appendChild(titleText)
title.appendChild(pubLink)
}
})
}
window.onload = () => {
getPubs()
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs && tabs[0]) {
const tabId = tabs[0].id
chrome.action.setBadgeText({ text: '', tabId })
}
})
}