blob: c4f994ff837539f45a58889818179f681ed89b2c [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ínezcb12c592024-11-09 20:46:03 +01006 ExtraInfoDependency,
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +02007 OptionsProviderDependency,
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +01008 StartupDataStorageDependency,
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +02009 WorkflowsImportDependency,
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020010} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
11import { Context } from '../../../common/architecture/entrypoint/Context';
12import {
13 ScriptEnvironment,
14 ScriptPage,
15 ScriptRunPhase,
16} from '../../../common/architecture/scripts/Script';
17import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler';
18import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler';
19import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020020import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010021import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/ecApp.handler';
22import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/reportDialog.handler';
23import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020024import Features from '../../../features/Features';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020025import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020026import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
27import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter';
28import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
29import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
30import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
31import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010032import StandaloneScripts from '../../../presentation/standaloneScripts/Scripts';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010033import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler';
34import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler';
35import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler';
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020036import WorkflowsThreadListActionBarHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/threadListActionBar.handler';
37import WorkflowsImportCRTagsHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/crTags.handler';
38import Workflows from '../../../features/workflows/core/communityConsole/workflows';
39import WorkflowsImportStylesheetScript from '../../../features/workflows/presentation/scripts/importStylesheet';
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010040import CCExtraInfoProfileAbuseChipsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfileAbuseChips.handler';
41import CCExtraInfoProfilePerForumStatsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfilePerForumStats.handler';
42import CCExtraInfoThreadCommentHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadComment.handler';
43import CCExtraInfoThreadListHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadList.handler';
44import CCExtraInfoThreadListToolbeltHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadListToolbelt.handler';
45import CCExtraInfoThreadQuestionHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadQuestion.handler';
46import CCExtraInfoThreadReplyHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadReply.handler';
47import CCExtraInfoInjectScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoInject.script';
48import CCExtraInfoStylesScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoStyles.script';
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010049import InjectLitComponentsScript from '../../../presentation/standaloneScripts/litComponents/injectLitComponents.script';
50import ApplyStartupDataModificationsOnMainScript from '../../../presentation/standaloneScripts/startupDataStorage/applyStartupDataModificationsOnMain.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020051
52const scriptRunner = createScriptRunner();
53scriptRunner.run();
54
55function createScriptRunner() {
56 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
57 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010058 const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency);
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020059 const optionsProvider = dependenciesProvider.getDependency(
60 OptionsProviderDependency,
61 );
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010062 const startupDataStorage = dependenciesProvider.getDependency(
63 StartupDataStorageDependency,
64 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020065 const workflowsImport = dependenciesProvider.getDependency(
66 WorkflowsImportDependency,
67 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020068
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020069 const ccInfiniteScroll = new CCInfiniteScroll();
70
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020071 const context: Context = {
72 page: ScriptPage.CommunityConsole,
73 environment: ScriptEnvironment.ContentScript,
74 runPhase: ScriptRunPhase.Main,
75 };
76
77 return new ScriptRunner(
78 new SortedScriptsProviderAdapter(
79 [
80 // Node watcher script with handlers
81 new NodeWatcherScriptAdapter(
82 new NodeWatcherAdapter(),
83 new Map<string, NodeWatcherHandler>([
84 [
85 'autoRefreshThreadListSetUp',
86 new AutoRefreshThreadListSetUpHandler(autoRefresh),
87 ],
88 [
89 'autoRefreshThreadListHide',
90 new AutoRefreshThreadListHideHandler(autoRefresh),
91 ],
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020092 ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)],
93 [
94 'ccDarkThemeReportDialog',
95 new CCDarkThemeReportDialogHandler(
96 optionsProvider,
97 new ReportDialogColorThemeFix(),
98 ),
99 ],
100 [
101 'ccDarkThemeUnifiedProfilesIframe',
102 new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider),
103 ],
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200104 [
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100105 'ccExtraInfoProfile',
106 new CCExtraInfoProfileAbuseChipsHandler(extraInfo),
107 ],
108 [
109 'ccExtraInfoProfilePerForumStats',
110 new CCExtraInfoProfilePerForumStatsHandler(extraInfo),
111 ],
112 [
113 'ccExtraInfoThreadComment',
114 new CCExtraInfoThreadCommentHandler(extraInfo),
115 ],
116 [
117 'ccExtraInfoThreadList',
118 new CCExtraInfoThreadListHandler(extraInfo),
119 ],
120 [
121 'ccExtraInfoThreadListToolbelt',
122 new CCExtraInfoThreadListToolbeltHandler(extraInfo),
123 ],
124 [
125 'ccExtraInfoThreadQuestion',
126 new CCExtraInfoThreadQuestionHandler(extraInfo),
127 ],
128 [
129 'ccExtraInfoThreadReply',
130 new CCExtraInfoThreadReplyHandler(extraInfo),
131 ],
132 [
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200133 'ccInfiniteScrollSetUp',
134 new CCInfiniteScrollSetUpHandler(ccInfiniteScroll),
135 ],
136 [
137 'ccInfiniteScrollLoadMoreBar',
138 new CCInfiniteScrollLoadMoreBarHandler(ccInfiniteScroll),
139 ],
140 [
141 'ccInfiniteScrollLoadMoreBtn',
142 new CCInfiniteScrollLoadMoreBtnHandler(ccInfiniteScroll),
143 ],
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200144 [
145 'workflowsImportCRTags',
146 new WorkflowsImportCRTagsHandler(workflowsImport),
147 ],
148 [
149 'workflowsThreadListActionBar',
150 new WorkflowsThreadListActionBarHandler(new Workflows()),
151 ],
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200152 ]),
153 ),
154
155 // Individual feature scripts
156 new AutoRefreshStylesScript(),
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100157 new CCExtraInfoInjectScript(),
158 new CCExtraInfoStylesScript(),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200159 new WorkflowsImportStylesheetScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200160
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +0100161 // Standalone scripts
162 new ApplyStartupDataModificationsOnMainScript(startupDataStorage),
163 new InjectLitComponentsScript(),
164
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200165 // Non-DI scripts (legacy, should be migrated to use a DI approach)
166 ...new Features().getScripts(context),
167 ...new StandaloneScripts().getScripts(context),
168 ],
169 new ScriptSorterAdapter(),
170 ).getScripts(),
171 );
172}