blob: cc545409d54883d918ba4b1985ad64142e6c9dff [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';
Adrià Vilanova Martíneze0d65f22022-11-06 18:49:35 +01005import WorkflowsImport from './workflows/import.js';
avm99963b6f68b62021-08-12 23:13:06 +02006
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +02007getOptions(null).then(options => {
Adrià Vilanova Martínezd2ac4ce2021-06-11 16:41:43 +02008 /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */
Adrià Vilanova Martínez879d44a2024-05-17 15:30:03 +02009 if (options.fixpekb269560789) {
avm99963b69eb3d2020-08-20 02:03:44 +020010 var startup =
Adrià Vilanova Martínez8423dfd2024-05-16 22:15:55 +020011 JSON.parse(document.querySelector('html').getAttribute('data-startup'));
Adrià Vilanova Martínez66dba7c2024-05-15 22:38:20 +020012
13 if (options.fixpekb269560789) {
14 if (startup[1]?.[1]?.[8]?.[7]) {
15 delete startup[1]?.[1]?.[8]?.[7];
16 }
17 }
avm99963c19497f2019-08-23 00:15:11 +020018
avm99963b69eb3d2020-08-20 02:03:44 +020019 document.querySelector('html').setAttribute(
20 'data-startup', JSON.stringify(startup));
avm999636d9c5fe2019-06-04 00:35:53 +020021 }
avm999630bc113a2020-09-07 13:02:11 +020022
Adrià Vilanova Martínez7e8796c2022-01-23 21:46:46 +010023 // Initialized here instead of in main.js so the first event is received if it
24 // happens when the page loads.
Adrià Vilanova Martíneze0d65f22022-11-06 18:49:35 +010025 window.TWPTWorkflowsImport = new WorkflowsImport();
avm99963b6f68b62021-08-12 23:13:06 +020026
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +020027 if (options.ccdarktheme) {
28 switch (options.ccdarktheme_mode) {
avm999630bc113a2020-09-07 13:02:11 +020029 case 'switch':
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +020030 if (options.ccdarktheme_switch_status == true)
Adrià Vilanova Martínezddd30042023-11-01 22:54:17 +010031 injectStylesheet(chrome.runtime.getURL('ccDarkTheme.bundle.css'));
avm999630bc113a2020-09-07 13:02:11 +020032 break;
33
34 case 'system':
Adrià Vilanova Martínezddd30042023-11-01 22:54:17 +010035 injectStylesheet(chrome.runtime.getURL('ccDarkTheme.bundle.css'), {
avm999630bc113a2020-09-07 13:02:11 +020036 'media': '(prefers-color-scheme: dark)',
37 });
38 break;
39 }
40 }
Adrià Vilanova Martíneza2f79512022-07-10 15:32:32 +020041
42 if (options.uispacing) {
43 injectStylesheet(chrome.runtime.getURL('css/ui_spacing/shared.css'));
44 injectStylesheet(chrome.runtime.getURL('css/ui_spacing/console.css'));
45 }
Adrià Vilanova Martínez72a4ea42024-02-09 22:35:32 +010046
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +020047 const flattenThreadsReplyActionHandler =
48 new FlattenThreadsReplyActionHandler(options);
Adrià Vilanova Martínez72a4ea42024-02-09 22:35:32 +010049 flattenThreadsReplyActionHandler.handleIfApplicable();
avm999636d9c5fe2019-06-04 00:35:53 +020050});