Adrià Vilanova Martínez | 66836fd | 2024-05-04 22:43:06 +0200 | [diff] [blame] | 1 | import {injectStylesheet} from '../../common/contentScriptsUtils.js'; |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 2 | import {getOptions} from '../../common/optionsUtils.js'; |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 3 | |
Adrià Vilanova Martínez | 72a4ea4 | 2024-02-09 22:35:32 +0100 | [diff] [blame] | 4 | import FlattenThreadsReplyActionHandler from './flattenThreads/replyActionHandler.js'; |
Adrià Vilanova Martínez | e0d65f2 | 2022-11-06 18:49:35 +0100 | [diff] [blame] | 5 | import WorkflowsImport from './workflows/import.js'; |
avm99963 | b6f68b6 | 2021-08-12 23:13:06 +0200 | [diff] [blame] | 6 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 7 | getOptions(null).then(options => { |
Adrià Vilanova Martínez | d2ac4ce | 2021-06-11 16:41:43 +0200 | [diff] [blame] | 8 | /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */ |
Adrià Vilanova Martínez | 879d44a | 2024-05-17 15:30:03 +0200 | [diff] [blame] | 9 | if (options.fixpekb269560789) { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 10 | var startup = |
Adrià Vilanova Martínez | 8423dfd | 2024-05-16 22:15:55 +0200 | [diff] [blame] | 11 | JSON.parse(document.querySelector('html').getAttribute('data-startup')); |
Adrià Vilanova Martínez | 66dba7c | 2024-05-15 22:38:20 +0200 | [diff] [blame] | 12 | |
| 13 | if (options.fixpekb269560789) { |
| 14 | if (startup[1]?.[1]?.[8]?.[7]) { |
| 15 | delete startup[1]?.[1]?.[8]?.[7]; |
| 16 | } |
| 17 | } |
avm99963 | c19497f | 2019-08-23 00:15:11 +0200 | [diff] [blame] | 18 | |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 19 | document.querySelector('html').setAttribute( |
| 20 | 'data-startup', JSON.stringify(startup)); |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 21 | } |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 22 | |
Adrià Vilanova Martínez | 7e8796c | 2022-01-23 21:46:46 +0100 | [diff] [blame] | 23 | // Initialized here instead of in main.js so the first event is received if it |
| 24 | // happens when the page loads. |
Adrià Vilanova Martínez | e0d65f2 | 2022-11-06 18:49:35 +0100 | [diff] [blame] | 25 | window.TWPTWorkflowsImport = new WorkflowsImport(); |
avm99963 | b6f68b6 | 2021-08-12 23:13:06 +0200 | [diff] [blame] | 26 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 27 | if (options.ccdarktheme) { |
| 28 | switch (options.ccdarktheme_mode) { |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 29 | case 'switch': |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 30 | if (options.ccdarktheme_switch_status == true) |
Adrià Vilanova Martínez | ddd3004 | 2023-11-01 22:54:17 +0100 | [diff] [blame] | 31 | injectStylesheet(chrome.runtime.getURL('ccDarkTheme.bundle.css')); |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 32 | break; |
| 33 | |
| 34 | case 'system': |
Adrià Vilanova Martínez | ddd3004 | 2023-11-01 22:54:17 +0100 | [diff] [blame] | 35 | injectStylesheet(chrome.runtime.getURL('ccDarkTheme.bundle.css'), { |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 36 | 'media': '(prefers-color-scheme: dark)', |
| 37 | }); |
| 38 | break; |
| 39 | } |
| 40 | } |
Adrià Vilanova Martínez | a2f7951 | 2022-07-10 15:32:32 +0200 | [diff] [blame] | 41 | |
| 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ínez | 72a4ea4 | 2024-02-09 22:35:32 +0100 | [diff] [blame] | 46 | |
Adrià Vilanova Martínez | 66836fd | 2024-05-04 22:43:06 +0200 | [diff] [blame] | 47 | const flattenThreadsReplyActionHandler = |
| 48 | new FlattenThreadsReplyActionHandler(options); |
Adrià Vilanova Martínez | 72a4ea4 | 2024-02-09 22:35:32 +0100 | [diff] [blame] | 49 | flattenThreadsReplyActionHandler.handleIfApplicable(); |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 50 | }); |