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