-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
27 lines (24 loc) · 1.03 KB
/
options.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
var successParagraph = document.getElementById("success-paragraph")
var failureParagraph = document.getElementById("failure-paragraph")
var loadingParagraph = document.getElementById("loading-paragraph")
var accessTokenInput = document.getElementById("access-token-input")
document.getElementById("access-token-form").addEventListener("submit", (event) => {
event.preventDefault()
failureParagraph.style.display = "none"
successParagraph.style.display = "none"
loadingParagraph.style.display = "block"
accessToken = accessTokenInput.value
chrome.storage.sync.set({accessToken}, function() {
chrome.runtime.sendMessage({accessToken}, function(response) {
if (response.success) {
loadingParagraph.style.display = "none"
successParagraph.style.display = "block"
accessTokenInput.value = ""
} else {
failureParagraph.innerHTML = `Error requesting the API: ${response.error}`
loadingParagraph.style.display = "none"
failureParagraph.style.display = "block"
}
});
});
})