-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathomdbApiKeyPage.js
More file actions
38 lines (32 loc) · 1.08 KB
/
omdbApiKeyPage.js
File metadata and controls
38 lines (32 loc) · 1.08 KB
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
const getRegisterBox = () => {
const input = html.textbox('Api Key')
const saveButton = html.button('Save Key')
saveButton.addEventListener(C.Action.Click, () => {
const key = input.value.trim()
if (!key) return
settings.set(Setting.OmdbApiKey, key)
container.innerHTML = ''
container.append('Success!')
})
const container = html.span()
container.append(input, ' ', saveButton)
return container
}
const initializePage = () => {
const freeRadio = document.getElementById('freeAcct')
const apiKeyUseInput = document.getElementById('TextArea1')
if (!freeRadio?.checked) {
freeRadio?.click()
} else {
apiKeyUseInput.value = 'Prime Video Ratings Chrome Extension'
const group = findParentByClass(apiKeyUseInput, 'form-group')
if (group) group.style.display = 'none'
const successLabel = document.getElementById('Label')
if (successLabel?.innerText?.includes('verification')) {
successLabel.innerHTML += "<br><br>Open the email, click the verification link, and paste your key here:<br>"
successLabel.after(getRegisterBox())
}
}
}
initializePage()
storage.load()