blob: 4812d53d0731bca235e0b2699e85c8af69c4bb97 [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ínezed1aba32024-10-26 21:23:12 +02008 WorkflowsImportDependency,
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +02009} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
10import { Context } from '../../../common/architecture/entrypoint/Context';
11import {
12 ScriptEnvironment,
13 ScriptPage,
14 ScriptRunPhase,
15} from '../../../common/architecture/scripts/Script';
16import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler';
17import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler';
18import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020019import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010020import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/ecApp.handler';
21import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/reportDialog.handler';
22import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020023import Features from '../../../features/Features';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020024import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020025import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
26import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter';
27import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
28import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
29import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
30import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
31import StandaloneScripts from '../../../scripts/Scripts';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010032import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler';
33import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler';
34import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler';
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020035import WorkflowsThreadListActionBarHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/threadListActionBar.handler';
36import WorkflowsImportCRTagsHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/crTags.handler';
37import Workflows from '../../../features/workflows/core/communityConsole/workflows';
38import WorkflowsImportStylesheetScript from '../../../features/workflows/presentation/scripts/importStylesheet';
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010039import CCExtraInfoProfileAbuseChipsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfileAbuseChips.handler';
40import CCExtraInfoProfilePerForumStatsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfilePerForumStats.handler';
41import CCExtraInfoThreadCommentHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadComment.handler';
42import CCExtraInfoThreadListHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadList.handler';
43import CCExtraInfoThreadListToolbeltHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadListToolbelt.handler';
44import CCExtraInfoThreadQuestionHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadQuestion.handler';
45import CCExtraInfoThreadReplyHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadReply.handler';
46import CCExtraInfoInjectScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoInject.script';
47import CCExtraInfoStylesScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoStyles.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020048
49const scriptRunner = createScriptRunner();
50scriptRunner.run();
51
52function createScriptRunner() {
53 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
54 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010055 const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency);
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020056 const optionsProvider = dependenciesProvider.getDependency(
57 OptionsProviderDependency,
58 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020059 const workflowsImport = dependenciesProvider.getDependency(
60 WorkflowsImportDependency,
61 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020062
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020063 const ccInfiniteScroll = new CCInfiniteScroll();
64
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020065 const context: Context = {
66 page: ScriptPage.CommunityConsole,
67 environment: ScriptEnvironment.ContentScript,
68 runPhase: ScriptRunPhase.Main,
69 };
70
71 return new ScriptRunner(
72 new SortedScriptsProviderAdapter(
73 [
74 // Node watcher script with handlers
75 new NodeWatcherScriptAdapter(
76 new NodeWatcherAdapter(),
77 new Map<string, NodeWatcherHandler>([
78 [
79 'autoRefreshThreadListSetUp',
80 new AutoRefreshThreadListSetUpHandler(autoRefresh),
81 ],
82 [
83 'autoRefreshThreadListHide',
84 new AutoRefreshThreadListHideHandler(autoRefresh),
85 ],
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020086 ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)],
87 [
88 'ccDarkThemeReportDialog',
89 new CCDarkThemeReportDialogHandler(
90 optionsProvider,
91 new ReportDialogColorThemeFix(),
92 ),
93 ],
94 [
95 'ccDarkThemeUnifiedProfilesIframe',
96 new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider),
97 ],
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020098 [
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010099 'ccExtraInfoProfile',
100 new CCExtraInfoProfileAbuseChipsHandler(extraInfo),
101 ],
102 [
103 'ccExtraInfoProfilePerForumStats',
104 new CCExtraInfoProfilePerForumStatsHandler(extraInfo),
105 ],
106 [
107 'ccExtraInfoThreadComment',
108 new CCExtraInfoThreadCommentHandler(extraInfo),
109 ],
110 [
111 'ccExtraInfoThreadList',
112 new CCExtraInfoThreadListHandler(extraInfo),
113 ],
114 [
115 'ccExtraInfoThreadListToolbelt',
116 new CCExtraInfoThreadListToolbeltHandler(extraInfo),
117 ],
118 [
119 'ccExtraInfoThreadQuestion',
120 new CCExtraInfoThreadQuestionHandler(extraInfo),
121 ],
122 [
123 'ccExtraInfoThreadReply',
124 new CCExtraInfoThreadReplyHandler(extraInfo),
125 ],
126 [
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200127 'ccInfiniteScrollSetUp',
128 new CCInfiniteScrollSetUpHandler(ccInfiniteScroll),
129 ],
130 [
131 'ccInfiniteScrollLoadMoreBar',
132 new CCInfiniteScrollLoadMoreBarHandler(ccInfiniteScroll),
133 ],
134 [
135 'ccInfiniteScrollLoadMoreBtn',
136 new CCInfiniteScrollLoadMoreBtnHandler(ccInfiniteScroll),
137 ],
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200138 [
139 'workflowsImportCRTags',
140 new WorkflowsImportCRTagsHandler(workflowsImport),
141 ],
142 [
143 'workflowsThreadListActionBar',
144 new WorkflowsThreadListActionBarHandler(new Workflows()),
145 ],
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200146 ]),
147 ),
148
149 // Individual feature scripts
150 new AutoRefreshStylesScript(),
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100151 new CCExtraInfoInjectScript(),
152 new CCExtraInfoStylesScript(),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200153 new WorkflowsImportStylesheetScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200154
155 // Non-DI scripts (legacy, should be migrated to use a DI approach)
156 ...new Features().getScripts(context),
157 ...new StandaloneScripts().getScripts(context),
158 ],
159 new ScriptSorterAdapter(),
160 ).getScripts(),
161 );
162}