Adrià Vilanova Martínez | ba3eeba | 2021-07-25 12:22:02 +0200 | [diff] [blame] | 1 | import {injectScript, injectStylesheet} from '../../common/contentScriptsUtils.js'; |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 2 | |
Adrià Vilanova Martínez | 2b87179 | 2021-06-09 12:35:06 +0200 | [diff] [blame] | 3 | const SMEI_UNIFIED_PROFILES = 9; |
| 4 | |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 5 | chrome.storage.sync.get(null, function(items) { |
Adrià Vilanova Martínez | d2ac4ce | 2021-06-11 16:41:43 +0200 | [diff] [blame] | 6 | /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */ |
Adrià Vilanova Martínez | ba3eeba | 2021-07-25 12:22:02 +0200 | [diff] [blame] | 7 | if (items.loaddrafts || 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 | |
Adrià Vilanova Martínez | 2b87179 | 2021-06-09 12:35:06 +0200 | [diff] [blame] | 15 | if (items.disableunifiedprofiles) { |
| 16 | var index = startup[1][6].indexOf(SMEI_UNIFIED_PROFILES); |
Adrià Vilanova Martínez | d2ac4ce | 2021-06-11 16:41:43 +0200 | [diff] [blame] | 17 | if (index > -1) startup[1][6].splice(index, 1); |
avm99963 | b38b741 | 2020-12-11 17:59:02 +0100 | [diff] [blame] | 18 | } |
| 19 | |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 20 | document.querySelector('html').setAttribute( |
| 21 | 'data-startup', JSON.stringify(startup)); |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 22 | } |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 23 | |
| 24 | if (items.ccdarktheme) { |
| 25 | switch (items.ccdarktheme_mode) { |
| 26 | case 'switch': |
| 27 | if (items.ccdarktheme_switch_status == true) |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 28 | injectStylesheet(chrome.runtime.getURL('css/ccdarktheme.css')); |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 29 | break; |
| 30 | |
| 31 | case 'system': |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 32 | injectStylesheet(chrome.runtime.getURL('css/ccdarktheme.css'), { |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 33 | 'media': '(prefers-color-scheme: dark)', |
| 34 | }); |
| 35 | break; |
| 36 | } |
| 37 | } |
Adrià Vilanova Martínez | 43ec2b9 | 2021-07-16 18:44:54 +0200 | [diff] [blame] | 38 | |
| 39 | injectScript(chrome.runtime.getURL('xhrInterceptorInject.bundle.js')); |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 40 | }); |