blob: 9c70743dd5d258943829d01480966b206f5b3fb2 [file] [log] [blame]
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +02001// Run legacy Javascript entry point
2import '../../../contentScripts/communityConsole/main';
3
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +02004import DependenciesProviderSingleton, {
5 AutoRefreshDependency,
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +02006 OptionsProviderDependency,
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +02007 WorkflowsImportDependency,
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +02008} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
9import { Context } from '../../../common/architecture/entrypoint/Context';
10import {
11 ScriptEnvironment,
12 ScriptPage,
13 ScriptRunPhase,
14} from '../../../common/architecture/scripts/Script';
15import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler';
16import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler';
17import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020018import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog';
19import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/ecApp.handler';
20import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/reportDialog.handler';
21import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/unifiedProfilesIframe.handler';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020022import Features from '../../../features/Features';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020023import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020024import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
25import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter';
26import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
27import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
28import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
29import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
30import StandaloneScripts from '../../../scripts/Scripts';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020031import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler';
32import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler';
33import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler';
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020034import WorkflowsThreadListActionBarHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/threadListActionBar.handler';
35import WorkflowsImportCRTagsHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/crTags.handler';
36import Workflows from '../../../features/workflows/core/communityConsole/workflows';
37import WorkflowsImportStylesheetScript from '../../../features/workflows/presentation/scripts/importStylesheet';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020038
39const scriptRunner = createScriptRunner();
40scriptRunner.run();
41
42function createScriptRunner() {
43 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
44 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020045 const optionsProvider = dependenciesProvider.getDependency(
46 OptionsProviderDependency,
47 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020048 const workflowsImport = dependenciesProvider.getDependency(
49 WorkflowsImportDependency,
50 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020051
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020052 const ccInfiniteScroll = new CCInfiniteScroll();
53
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020054 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ínez6ecaa0d2024-10-26 17:04:32 +020075 ['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ínez7c941c72024-10-26 20:23:34 +020087 [
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ínezed1aba32024-10-26 21:23:12 +020099 [
100 'workflowsImportCRTags',
101 new WorkflowsImportCRTagsHandler(workflowsImport),
102 ],
103 [
104 'workflowsThreadListActionBar',
105 new WorkflowsThreadListActionBarHandler(new Workflows()),
106 ],
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200107 ]),
108 ),
109
110 // Individual feature scripts
111 new AutoRefreshStylesScript(),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200112 new WorkflowsImportStylesheetScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200113
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}