Adrià Vilanova Martínez | 2b87179 | 2021-06-09 12:35:06 +0200 | [diff] [blame] | 1 | const SMEI_SORT_DIRECTION = 8; |
| 2 | const SMEI_UNIFIED_PROFILES = 9; |
| 3 | |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 4 | chrome.storage.sync.get(null, function(items) { |
Adrià Vilanova Martínez | d2ac4ce | 2021-06-11 16:41:43 +0200 | [diff] [blame] | 5 | /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */ |
| 6 | if (items.loaddrafts || items.smei_sortdirection || |
| 7 | items.disableunifiedprofiles) { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 8 | var startup = |
| 9 | JSON.parse(document.querySelector('html').getAttribute('data-startup')); |
avm99963 | c19497f | 2019-08-23 00:15:11 +0200 | [diff] [blame] | 10 | |
| 11 | if (items.loaddrafts) { |
| 12 | startup[4][13] = true; |
| 13 | } |
| 14 | |
avm99963 | b38b741 | 2020-12-11 17:59:02 +0100 | [diff] [blame] | 15 | if (items.smei_sortdirection) { |
Adrià Vilanova Martínez | 2b87179 | 2021-06-09 12:35:06 +0200 | [diff] [blame] | 16 | 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ínez | d2ac4ce | 2021-06-11 16:41:43 +0200 | [diff] [blame] | 22 | if (index > -1) startup[1][6].splice(index, 1); |
avm99963 | b38b741 | 2020-12-11 17:59:02 +0100 | [diff] [blame] | 23 | } |
| 24 | |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 25 | document.querySelector('html').setAttribute( |
| 26 | 'data-startup', JSON.stringify(startup)); |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 27 | } |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 28 | |
| 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 | } |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 43 | }); |