blob: bb7fe6a6f3f1ee07a2f510938683a4866bdb7fe0 [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ínezf92172f2024-10-19 15:55:15 +02007} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
8import { Context } from '../../../common/architecture/entrypoint/Context';
9import {
10 ScriptEnvironment,
11 ScriptPage,
12 ScriptRunPhase,
13} from '../../../common/architecture/scripts/Script';
14import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler';
15import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler';
16import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020017import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog';
18import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/ecApp.handler';
19import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/reportDialog.handler';
20import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/unifiedProfilesIframe.handler';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020021import Features from '../../../features/Features';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020022import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020023import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
24import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter';
25import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
26import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
27import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
28import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
29import StandaloneScripts from '../../../scripts/Scripts';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020030import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler';
31import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler';
32import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020033
34const scriptRunner = createScriptRunner();
35scriptRunner.run();
36
37function createScriptRunner() {
38 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
39 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020040 const optionsProvider = dependenciesProvider.getDependency(
41 OptionsProviderDependency,
42 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020043
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020044 const ccInfiniteScroll = new CCInfiniteScroll();
45
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020046 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ínez6ecaa0d2024-10-26 17:04:32 +020067 ['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ínez7c941c72024-10-26 20:23:34 +020079 [
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ínezf92172f2024-10-19 15:55:15 +020091 ]),
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}