21 lines
589 B
JavaScript
21 lines
589 B
JavaScript
const SERVER_BASE = "https://youtube.marha.de";
|
|
|
|
browser.runtime.onMessage.addListener((msg) => {
|
|
if (msg?.type === "sync-cookies") {
|
|
return syncCookies();
|
|
}
|
|
if (msg?.profileId && msg?.video) {
|
|
fetch(`${SERVER_BASE}/profiles/${msg.profileId}/videos`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(msg.video),
|
|
}).catch(() => {});
|
|
}
|
|
});
|
|
|
|
syncCookies();
|
|
browser.alarms.create("cookieSync", { periodInMinutes: 1440 });
|
|
browser.alarms.onAlarm.addListener((a) => {
|
|
if (a.name === "cookieSync") syncCookies();
|
|
});
|