Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 1 | // Run legacy Javascript entry point |
| 2 | import '../../../contentScripts/communityConsole/main'; |
| 3 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 4 | import DependenciesProviderSingleton, { |
| 5 | AutoRefreshDependency, |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 6 | OptionsProviderDependency, |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 7 | } from '../../../common/architecture/dependenciesProvider/DependenciesProvider'; |
| 8 | import { Context } from '../../../common/architecture/entrypoint/Context'; |
| 9 | import { |
| 10 | ScriptEnvironment, |
| 11 | ScriptPage, |
| 12 | ScriptRunPhase, |
| 13 | } from '../../../common/architecture/scripts/Script'; |
| 14 | import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler'; |
| 15 | import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler'; |
| 16 | import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script'; |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 17 | import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog'; |
| 18 | import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/ecApp.handler'; |
| 19 | import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/reportDialog.handler'; |
| 20 | import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/unifiedProfilesIframe.handler'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 21 | import Features from '../../../features/Features'; |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 22 | import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 23 | import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter'; |
| 24 | import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter'; |
| 25 | import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner'; |
| 26 | import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter'; |
| 27 | import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter'; |
| 28 | import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler'; |
| 29 | import StandaloneScripts from '../../../scripts/Scripts'; |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 30 | import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler'; |
| 31 | import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler'; |
| 32 | import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 33 | |
| 34 | const scriptRunner = createScriptRunner(); |
| 35 | scriptRunner.run(); |
| 36 | |
| 37 | function createScriptRunner() { |
| 38 | const dependenciesProvider = DependenciesProviderSingleton.getInstance(); |
| 39 | const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency); |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 40 | const optionsProvider = dependenciesProvider.getDependency( |
| 41 | OptionsProviderDependency, |
| 42 | ); |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 43 | |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 44 | const ccInfiniteScroll = new CCInfiniteScroll(); |
| 45 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 46 | const context: Context = { |
| 47 | page: ScriptPage.CommunityConsole, |
| 48 | environment: ScriptEnvironment.ContentScript, |
| 49 | runPhase: ScriptRunPhase.Main, |
| 50 | }; |
| 51 | |
| 52 | return new ScriptRunner( |
| 53 | new SortedScriptsProviderAdapter( |
| 54 | [ |
| 55 | // Node watcher script with handlers |
| 56 | new NodeWatcherScriptAdapter( |
| 57 | new NodeWatcherAdapter(), |
| 58 | new Map<string, NodeWatcherHandler>([ |
| 59 | [ |
| 60 | 'autoRefreshThreadListSetUp', |
| 61 | new AutoRefreshThreadListSetUpHandler(autoRefresh), |
| 62 | ], |
| 63 | [ |
| 64 | 'autoRefreshThreadListHide', |
| 65 | new AutoRefreshThreadListHideHandler(autoRefresh), |
| 66 | ], |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 67 | ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)], |
| 68 | [ |
| 69 | 'ccDarkThemeReportDialog', |
| 70 | new CCDarkThemeReportDialogHandler( |
| 71 | optionsProvider, |
| 72 | new ReportDialogColorThemeFix(), |
| 73 | ), |
| 74 | ], |
| 75 | [ |
| 76 | 'ccDarkThemeUnifiedProfilesIframe', |
| 77 | new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider), |
| 78 | ], |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 79 | [ |
| 80 | 'ccInfiniteScrollSetUp', |
| 81 | new CCInfiniteScrollSetUpHandler(ccInfiniteScroll), |
| 82 | ], |
| 83 | [ |
| 84 | 'ccInfiniteScrollLoadMoreBar', |
| 85 | new CCInfiniteScrollLoadMoreBarHandler(ccInfiniteScroll), |
| 86 | ], |
| 87 | [ |
| 88 | 'ccInfiniteScrollLoadMoreBtn', |
| 89 | new CCInfiniteScrollLoadMoreBtnHandler(ccInfiniteScroll), |
| 90 | ], |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 91 | ]), |
| 92 | ), |
| 93 | |
| 94 | // Individual feature scripts |
| 95 | new AutoRefreshStylesScript(), |
| 96 | |
| 97 | // Non-DI scripts (legacy, should be migrated to use a DI approach) |
| 98 | ...new Features().getScripts(context), |
| 99 | ...new StandaloneScripts().getScripts(context), |
| 100 | ], |
| 101 | new ScriptSorterAdapter(), |
| 102 | ).getScripts(), |
| 103 | ); |
| 104 | } |