forked from buildspace/buildspace-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
33 lines (28 loc) · 1.25 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
const form = document.getElementById("form")
form.addEventListener("submit", e => {
e.preventDefault();
const title = e.target.title.value;
const image = e.target.image.value;
const video = e.target.video.value;
const autoplay = e.target.autoplay.checked && "autoplay";
const loop = e.target.loop.checked && "loop";
const muted = e.target.muted.checked && "muted";
const controls = e.target.controls.checked && "controls";
const html = e.target.html.value;
chrome.storage.sync.set({ title, image, video, autoplay, loop, muted, controls, html })
chrome.runtime.sendMessage({ title, image, video, autoplay, loop, muted, controls, html })
})
chrome.storage.sync.get(["title", "image", "video", "autoplay", "loop", "muted", "controls", "html"], data => {
const { title, image, video, autoplay, loop, muted, controls, html } = data;
form.title.value = title || "";
form.image.value = image || "";
form.video.value = video || "";
form.autoplay.checked = autoplay ? true : false;
form.loop.checked = loop ? true : false;
form.muted.checked = muted ? true : false;
form.controls.checked = controls ? true :false;
form.html.value = html || "";
})
document.getElementById("refresh").addEventListener("click", () => {
window.location.reload();
})