-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
48 lines (40 loc) · 1.83 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
46
47
48
// populate options with stored values
document.querySelectorAll('*[data-option_key]').forEach(async inputEl => {
const storedData = await chrome.storage.sync.get(inputEl.dataset.option_key)
// get saved value if exists
if (storedData[inputEl.dataset.option_key]) {
inputEl.value = storedData[inputEl.dataset.option_key]
}
})
// listen for changes to options
document.addEventListener('input', async event => {
const inputEl = event.target
await chrome.storage.sync.set({
[inputEl.dataset.option_key]: inputEl.value
})
})
// listen for watched listings link click
document.querySelector('#watched_listings_link').addEventListener('click', (event) => {
event.preventDefault()
chrome.runtime.sendMessage({ action: 'SHOW_WATCHED_LISTINGS' })
})
// listen for test ending but winning notification link click
document.querySelector('#test_ending_winning_notification').addEventListener('click', (event) => {
event.preventDefault()
chrome.runtime.sendMessage({ action: 'TEST_ENDING_WINNING_NOTIFICATION' })
})
// listen for test ending and losing notification link click
document.querySelector('#test_ending_losing_notification').addEventListener('click', (event) => {
event.preventDefault()
chrome.runtime.sendMessage({ action: 'TEST_ENDING_LOSING_NOTIFICATION' })
})
// listen for test outbid notification link click
document.querySelector('#test_outbid_notification').addEventListener('click', (event) => {
event.preventDefault()
chrome.runtime.sendMessage({ action: 'TEST_OUTBID_NOTIFICATION' })
})
// listen for test item won notification link click
document.querySelector('#test_item_won_notification').addEventListener('click', (event) => {
event.preventDefault()
chrome.runtime.sendMessage({ action: 'TEST_ITEM_WON_NOTIFICATION' })
})