blob: 782569fcf4d256c739bba39ab0dc6d2e849ac3b7 [file] [log] [blame]
Adrià Vilanova Martínezba3eeba2021-07-25 12:22:02 +02001import {injectScript, injectStylesheet} from '../../common/contentScriptsUtils.js';
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +02002
Adrià Vilanova Martínez2b871792021-06-09 12:35:06 +02003const SMEI_UNIFIED_PROFILES = 9;
4
avm999636d9c5fe2019-06-04 00:35:53 +02005chrome.storage.sync.get(null, function(items) {
Adrià Vilanova Martínezd2ac4ce2021-06-11 16:41:43 +02006 /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */
Adrià Vilanova Martínezba3eeba2021-07-25 12:22:02 +02007 if (items.loaddrafts || 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
Adrià Vilanova Martínez2b871792021-06-09 12:35:06 +020015 if (items.disableunifiedprofiles) {
16 var index = startup[1][6].indexOf(SMEI_UNIFIED_PROFILES);
Adrià Vilanova Martínezd2ac4ce2021-06-11 16:41:43 +020017 if (index > -1) startup[1][6].splice(index, 1);
avm99963b38b7412020-12-11 17:59:02 +010018 }
19
avm99963b69eb3d2020-08-20 02:03:44 +020020 document.querySelector('html').setAttribute(
21 'data-startup', JSON.stringify(startup));
avm999636d9c5fe2019-06-04 00:35:53 +020022 }
avm999630bc113a2020-09-07 13:02:11 +020023
24 if (items.ccdarktheme) {
25 switch (items.ccdarktheme_mode) {
26 case 'switch':
27 if (items.ccdarktheme_switch_status == true)
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020028 injectStylesheet(chrome.runtime.getURL('css/ccdarktheme.css'));
avm999630bc113a2020-09-07 13:02:11 +020029 break;
30
31 case 'system':
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020032 injectStylesheet(chrome.runtime.getURL('css/ccdarktheme.css'), {
avm999630bc113a2020-09-07 13:02:11 +020033 'media': '(prefers-color-scheme: dark)',
34 });
35 break;
36 }
37 }
Adrià Vilanova Martínez43ec2b92021-07-16 18:44:54 +020038
39 injectScript(chrome.runtime.getURL('xhrInterceptorInject.bundle.js'));
avm999636d9c5fe2019-06-04 00:35:53 +020040});