blob: cf5a7a5c0038524042e4753682dbdc125b017492 [file] [log] [blame]
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +02001import {injectStylesheet} from '../../common/contentScriptsUtils.js';
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +02002import {getOptions} from '../../common/optionsUtils.js';
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +02003
Adrià Vilanova Martínez72a4ea42024-02-09 22:35:32 +01004import FlattenThreadsReplyActionHandler from './flattenThreads/replyActionHandler.js';
avm99963b6f68b62021-08-12 23:13:06 +02005
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +02006getOptions(null).then(options => {
Adrià Vilanova Martínezd2ac4ce2021-06-11 16:41:43 +02007 /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */
Adrià Vilanova Martínez879d44a2024-05-17 15:30:03 +02008 if (options.fixpekb269560789) {
avm99963b69eb3d2020-08-20 02:03:44 +02009 var startup =
Adrià Vilanova Martínez8423dfd2024-05-16 22:15:55 +020010 JSON.parse(document.querySelector('html').getAttribute('data-startup'));
Adrià Vilanova Martínez66dba7c2024-05-15 22:38:20 +020011
12 if (options.fixpekb269560789) {
13 if (startup[1]?.[1]?.[8]?.[7]) {
14 delete startup[1]?.[1]?.[8]?.[7];
15 }
16 }
avm99963c19497f2019-08-23 00:15:11 +020017
avm99963b69eb3d2020-08-20 02:03:44 +020018 document.querySelector('html').setAttribute(
19 'data-startup', JSON.stringify(startup));
avm999636d9c5fe2019-06-04 00:35:53 +020020 }
avm999630bc113a2020-09-07 13:02:11 +020021
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +020022 if (options.ccdarktheme) {
23 switch (options.ccdarktheme_mode) {
avm999630bc113a2020-09-07 13:02:11 +020024 case 'switch':
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +020025 if (options.ccdarktheme_switch_status == true)
Adrià Vilanova Martínezddd30042023-11-01 22:54:17 +010026 injectStylesheet(chrome.runtime.getURL('ccDarkTheme.bundle.css'));
avm999630bc113a2020-09-07 13:02:11 +020027 break;
28
29 case 'system':
Adrià Vilanova Martínezddd30042023-11-01 22:54:17 +010030 injectStylesheet(chrome.runtime.getURL('ccDarkTheme.bundle.css'), {
avm999630bc113a2020-09-07 13:02:11 +020031 'media': '(prefers-color-scheme: dark)',
32 });
33 break;
34 }
35 }
Adrià Vilanova Martíneza2f79512022-07-10 15:32:32 +020036
37 if (options.uispacing) {
38 injectStylesheet(chrome.runtime.getURL('css/ui_spacing/shared.css'));
39 injectStylesheet(chrome.runtime.getURL('css/ui_spacing/console.css'));
40 }
Adrià Vilanova Martínez72a4ea42024-02-09 22:35:32 +010041
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +020042 const flattenThreadsReplyActionHandler =
43 new FlattenThreadsReplyActionHandler(options);
Adrià Vilanova Martínez72a4ea42024-02-09 22:35:32 +010044 flattenThreadsReplyActionHandler.handleIfApplicable();
avm999636d9c5fe2019-06-04 00:35:53 +020045});