-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
45 lines (40 loc) · 1.2 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
const jobList = document.querySelector("#job-list")
const refreshList = document.querySelector("#refresh-list")
const clearList = document.querySelector("#clear-list")
chrome.runtime.onMessage.addListener(() => {
updateJobs()
})
const updateJobs = () => {
jobList.innerHTML = ``
chrome.storage.local.get("jobs", (result) => {
if (result?.jobs !== undefined) {
clearList.style.display = "initial"
result.jobs.forEach((job) => {
const appliedAt = new Date(job.appliedAt)
jobList.innerHTML += `<li>
<span class="applied_at" title=${appliedAt.toLocaleTimeString()}>${appliedAt.toLocaleDateString()}</span>
-
<a class="business" href=${job.businessUrl} target="_blank">${
job.business
}</a>
-
<a class="url" href=${job.url} target="_blank">${job.name}</a>
(${job.workplace})
</li>`
})
} else clearList.style.display = "none"
})
}
updateJobs()
refreshList.addEventListener("click", () => {
updateJobs()
})
clearList.addEventListener("click", () => {
chrome.storage.local.clear(() => {
const error = chrome.runtime.lastError
if (error) {
console.error(error)
}
})
updateJobs()
})