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) { |
avm99963 | db412d9 | 2020-12-31 19:27:59 +0100 | [diff] [blame] | 5 | if (items.loaddrafts || items.smei_sortdirection) { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 6 | var startup = |
| 7 | JSON.parse(document.querySelector('html').getAttribute('data-startup')); |
avm99963 | c19497f | 2019-08-23 00:15:11 +0200 | [diff] [blame] | 8 | |
| 9 | if (items.loaddrafts) { |
| 10 | startup[4][13] = true; |
| 11 | } |
| 12 | |
avm99963 | b38b741 | 2020-12-11 17:59:02 +0100 | [diff] [blame] | 13 | if (items.smei_sortdirection) { |
Adrià Vilanova Martínez | 2b87179 | 2021-06-09 12:35:06 +0200 | [diff] [blame] | 14 | if (!startup[1][6].includes(SMEI_SORT_DIRECTION)) |
| 15 | startup[1][6].push(SMEI_SORT_DIRECTION); |
| 16 | } |
| 17 | |
| 18 | if (items.disableunifiedprofiles) { |
| 19 | var index = startup[1][6].indexOf(SMEI_UNIFIED_PROFILES); |
| 20 | if (index > -1) |
| 21 | startup[1][6].splice(index, 1); |
avm99963 | b38b741 | 2020-12-11 17:59:02 +0100 | [diff] [blame] | 22 | } |
| 23 | |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 24 | document.querySelector('html').setAttribute( |
| 25 | 'data-startup', JSON.stringify(startup)); |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 26 | } |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 27 | |
| 28 | if (items.ccdarktheme) { |
| 29 | switch (items.ccdarktheme_mode) { |
| 30 | case 'switch': |
| 31 | if (items.ccdarktheme_switch_status == true) |
| 32 | injectStylesheet(chrome.runtime.getURL('injections/ccdarktheme.css')); |
| 33 | break; |
| 34 | |
| 35 | case 'system': |
| 36 | injectStylesheet(chrome.runtime.getURL('injections/ccdarktheme.css'), { |
| 37 | 'media': '(prefers-color-scheme: dark)', |
| 38 | }); |
| 39 | break; |
| 40 | } |
| 41 | } |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 42 | }); |