-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
33 lines (30 loc) · 978 Bytes
/
Copy pathpopup.js
File metadata and controls
33 lines (30 loc) · 978 Bytes
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
document.addEventListener("DOMContentLoaded", () => {
const input = document.getElementById("videoUrl");
const preset = document.getElementById("preset");
const saveBtn = document.getElementById("saveBtn");
// Load current video URL
chrome.storage.local.get(["bgVideo"], (result) => {
if (result.bgVideo) {
input.value = result.bgVideo;
}
});
// When user selects a preset
preset.addEventListener("change", () => {
if (preset.value) {
input.value = preset.value; // auto-fill the input
}
});
// Save video URL
saveBtn.addEventListener("click", () => {
const url = input.value.trim();
if (url) {
chrome.storage.local.set({ bgVideo: url }, () => {
chrome.tabs.query({ url: "https://anilist.co/*" }, (tabs) => {
tabs.forEach(tab => {
chrome.tabs.sendMessage(tab.id, { action: "updateVideo", url });
});
});
});
}
});
});