blob: 32f3159c1b3a14f34fc65d8ba5cd429b6e9f8053 [file] [log] [blame]
Adrià Vilanova Martínez2b871792021-06-09 12:35:06 +02001const SMEI_SORT_DIRECTION = 8;
2const SMEI_UNIFIED_PROFILES = 9;
3
avm999636d9c5fe2019-06-04 00:35:53 +02004chrome.storage.sync.get(null, function(items) {
Adrià Vilanova Martínezd2ac4ce2021-06-11 16:41:43 +02005 /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */
6 if (items.loaddrafts || items.smei_sortdirection ||
7 items.disableunifiedprofiles) {
avm99963b69eb3d2020-08-20 02:03:44 +02008 var startup =
9 JSON.parse(document.querySelector('html').getAttribute('data-startup'));
avm99963c19497f2019-08-23 00:15:11 +020010
11 if (items.loaddrafts) {
12 startup[4][13] = true;
13 }
14
avm99963b38b7412020-12-11 17:59:02 +010015 if (items.smei_sortdirection) {
Adrià Vilanova Martínez2b871792021-06-09 12:35:06 +020016 if (!startup[1][6].includes(SMEI_SORT_DIRECTION))
17 startup[1][6].push(SMEI_SORT_DIRECTION);
18 }
19
20 if (items.disableunifiedprofiles) {
21 var index = startup[1][6].indexOf(SMEI_UNIFIED_PROFILES);
Adrià Vilanova Martínezd2ac4ce2021-06-11 16:41:43 +020022 if (index > -1) startup[1][6].splice(index, 1);
avm99963b38b7412020-12-11 17:59:02 +010023 }
24
avm99963b69eb3d2020-08-20 02:03:44 +020025 document.querySelector('html').setAttribute(
26 'data-startup', JSON.stringify(startup));
avm999636d9c5fe2019-06-04 00:35:53 +020027 }
avm999630bc113a2020-09-07 13:02:11 +020028
29 if (items.ccdarktheme) {
30 switch (items.ccdarktheme_mode) {
31 case 'switch':
32 if (items.ccdarktheme_switch_status == true)
33 injectStylesheet(chrome.runtime.getURL('injections/ccdarktheme.css'));
34 break;
35
36 case 'system':
37 injectStylesheet(chrome.runtime.getURL('injections/ccdarktheme.css'), {
38 'media': '(prefers-color-scheme: dark)',
39 });
40 break;
41 }
42 }
avm999636d9c5fe2019-06-04 00:35:53 +020043});