2021-04-16 02:45:15 +02:00
|
|
|
"use strict";
|
2020-05-08 14:40:07 +02:00
|
|
|
|
|
|
|
window.browser = window.browser || window.chrome;
|
|
|
|
|
|
|
|
function getCookie() {
|
2021-04-16 02:45:15 +02:00
|
|
|
let ca = document.cookie.split(";");
|
2020-05-08 14:40:07 +02:00
|
|
|
for (let i = 0; i < ca.length; i++) {
|
|
|
|
let c = ca[i];
|
2021-04-16 02:45:15 +02:00
|
|
|
while (c.charAt(0) == " ") c = c.substring(1, c.length);
|
|
|
|
if (c.indexOf("PREFS=") == 0) {
|
2020-05-08 14:40:07 +02:00
|
|
|
return JSON.parse(
|
2021-04-16 02:45:15 +02:00
|
|
|
decodeURIComponent(c.substring("PREFS=".length, c.length))
|
|
|
|
);
|
|
|
|
}
|
2020-05-08 14:40:07 +02:00
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
browser.storage.sync.get(
|
2021-04-16 02:45:15 +02:00
|
|
|
["alwaysProxy", "videoQuality", "invidiousDarkMode", "persistInvidiousPrefs"],
|
2020-05-08 14:40:07 +02:00
|
|
|
(result) => {
|
|
|
|
if (result.persistInvidiousPrefs) {
|
|
|
|
const prefs = getCookie();
|
|
|
|
prefs.local = result.alwaysProxy;
|
|
|
|
prefs.quality = result.videoQuality;
|
|
|
|
prefs.dark_mode = result.invidiousDarkMode;
|
|
|
|
document.cookie = `PREFS=${encodeURIComponent(JSON.stringify(prefs))}`;
|
|
|
|
}
|
|
|
|
}
|
2021-04-16 02:45:15 +02:00
|
|
|
);
|