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 | 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 | |
avm99963 | b6f68b6 | 2021-08-12 23:13:06 +0200 | [diff] [blame] | 4 | import AutoRefresh from './autoRefresh.js'; |
| 5 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 6 | getOptions(null).then(options => { |
Adrià Vilanova Martínez | d2ac4ce | 2021-06-11 16:41:43 +0200 | [diff] [blame] | 7 | /* IMPORTANT NOTE: Remember to change this when changing the "ifs" below!! */ |
Adrià Vilanova Martínez | 2d22c4a | 2021-09-06 00:35:18 +0200 | [diff] [blame] | 8 | if (options.loaddrafts) { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 9 | var startup = |
| 10 | JSON.parse(document.querySelector('html').getAttribute('data-startup')); |
avm99963 | c19497f | 2019-08-23 00:15:11 +0200 | [diff] [blame] | 11 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 12 | if (options.loaddrafts) { |
avm99963 | c19497f | 2019-08-23 00:15:11 +0200 | [diff] [blame] | 13 | startup[4][13] = true; |
| 14 | } |
| 15 | |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 16 | document.querySelector('html').setAttribute( |
| 17 | 'data-startup', JSON.stringify(startup)); |
avm99963 | 6d9c5fe | 2019-06-04 00:35:53 +0200 | [diff] [blame] | 18 | } |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 19 | |
avm99963 | b6f68b6 | 2021-08-12 23:13:06 +0200 | [diff] [blame] | 20 | // Initialized here instead of in main.js so the first |ViewForumResponse| |
| 21 | // event is received if it happens when the page loads. |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 22 | window.TWPTAutoRefresh = new AutoRefresh(); |
avm99963 | b6f68b6 | 2021-08-12 23:13:06 +0200 | [diff] [blame] | 23 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 24 | if (options.ccdarktheme) { |
| 25 | switch (options.ccdarktheme_mode) { |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 26 | case 'switch': |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 27 | if (options.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 | }); |