blob: 2274fd0bd235537c2a3a338886bb202682af3a5a [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ínez4e847f42024-11-09 23:03:32 +01009 ThreadPageDesignWarningDependency,
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020010 WorkflowsImportDependency,
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020011} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020012import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler';
13import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler';
14import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020015import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010016import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/ecApp.handler';
17import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/reportDialog.handler';
18import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020019import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020020import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
21import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter';
22import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
23import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
24import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
25import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010026import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler';
27import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler';
28import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler';
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020029import WorkflowsThreadListActionBarHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/threadListActionBar.handler';
30import WorkflowsImportCRTagsHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/crTags.handler';
31import Workflows from '../../../features/workflows/core/communityConsole/workflows';
32import WorkflowsImportStylesheetScript from '../../../features/workflows/presentation/scripts/importStylesheet';
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010033import CCExtraInfoProfileAbuseChipsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfileAbuseChips.handler';
34import CCExtraInfoProfilePerForumStatsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfilePerForumStats.handler';
35import CCExtraInfoThreadCommentHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadComment.handler';
36import CCExtraInfoThreadListHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadList.handler';
37import CCExtraInfoThreadListToolbeltHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadListToolbelt.handler';
38import CCExtraInfoThreadQuestionHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadQuestion.handler';
39import CCExtraInfoThreadReplyHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadReply.handler';
40import CCExtraInfoInjectScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoInject.script';
41import CCExtraInfoStylesScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoStyles.script';
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010042import InjectLitComponentsScript from '../../../presentation/standaloneScripts/litComponents/injectLitComponents.script';
43import ApplyStartupDataModificationsOnMainScript from '../../../presentation/standaloneScripts/startupDataStorage/applyStartupDataModificationsOnMain.script';
Adrià Vilanova Martínez4e847f42024-11-09 23:03:32 +010044import ThreadPageDesignWarningInjectHandler from '../../../features/threadPageDesignWarning/presentation/nodeWatcherHandlers/inject.handler';
Adrià Vilanova Martínez3c13a762024-11-09 23:03:32 +010045import FlattenThreadsAdditionalInfoHandler from '../../../features/flattenThreads/presentation/nodeWatcherHandlers/additionalInfo.handler';
46import FlattenThreadsQuoteHandler from '../../../features/flattenThreads/presentation/nodeWatcherHandlers/quote.handler';
47import FlattenThreadsReaddReplyBtnHandler from '../../../features/flattenThreads/presentation/nodeWatcherHandlers/readdReplyBtn.handler';
48import FlattenThreadsReplyBtnHandler from '../../../features/flattenThreads/presentation/nodeWatcherHandlers/replyBtn.handler';
49import FlattenThreads from '../../../features/flattenThreads/core/flattenThreads';
50import FlattenThreadsStylesScript from '../../../features/flattenThreads/presentation/scripts/styles.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ínez4e847f42024-11-09 23:03:32 +010065 const threadPageDesignWarning = dependenciesProvider.getDependency(
66 ThreadPageDesignWarningDependency,
67 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020068 const workflowsImport = dependenciesProvider.getDependency(
69 WorkflowsImportDependency,
70 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020071
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020072 const ccInfiniteScroll = new CCInfiniteScroll();
Adrià Vilanova Martínez3c13a762024-11-09 23:03:32 +010073 const flattenThreads = new FlattenThreads();
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020074
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020075 return new ScriptRunner(
76 new SortedScriptsProviderAdapter(
77 [
78 // Node watcher script with handlers
79 new NodeWatcherScriptAdapter(
80 new NodeWatcherAdapter(),
81 new Map<string, NodeWatcherHandler>([
82 [
83 'autoRefreshThreadListSetUp',
84 new AutoRefreshThreadListSetUpHandler(autoRefresh),
85 ],
86 [
87 'autoRefreshThreadListHide',
88 new AutoRefreshThreadListHideHandler(autoRefresh),
89 ],
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020090 ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)],
91 [
92 'ccDarkThemeReportDialog',
93 new CCDarkThemeReportDialogHandler(
94 optionsProvider,
95 new ReportDialogColorThemeFix(),
96 ),
97 ],
98 [
99 'ccDarkThemeUnifiedProfilesIframe',
100 new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider),
101 ],
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200102 [
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100103 'ccExtraInfoProfile',
104 new CCExtraInfoProfileAbuseChipsHandler(extraInfo),
105 ],
106 [
107 'ccExtraInfoProfilePerForumStats',
108 new CCExtraInfoProfilePerForumStatsHandler(extraInfo),
109 ],
110 [
111 'ccExtraInfoThreadComment',
112 new CCExtraInfoThreadCommentHandler(extraInfo),
113 ],
114 [
115 'ccExtraInfoThreadList',
116 new CCExtraInfoThreadListHandler(extraInfo),
117 ],
118 [
119 'ccExtraInfoThreadListToolbelt',
120 new CCExtraInfoThreadListToolbeltHandler(extraInfo),
121 ],
122 [
123 'ccExtraInfoThreadQuestion',
124 new CCExtraInfoThreadQuestionHandler(extraInfo),
125 ],
126 [
127 'ccExtraInfoThreadReply',
128 new CCExtraInfoThreadReplyHandler(extraInfo),
129 ],
130 [
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200131 'ccInfiniteScrollSetUp',
132 new CCInfiniteScrollSetUpHandler(ccInfiniteScroll),
133 ],
134 [
135 'ccInfiniteScrollLoadMoreBar',
136 new CCInfiniteScrollLoadMoreBarHandler(ccInfiniteScroll),
137 ],
138 [
139 'ccInfiniteScrollLoadMoreBtn',
140 new CCInfiniteScrollLoadMoreBtnHandler(ccInfiniteScroll),
141 ],
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200142 [
Adrià Vilanova Martínez3c13a762024-11-09 23:03:32 +0100143 'flattenThreadsAdditionalInfo',
144 new FlattenThreadsAdditionalInfoHandler(flattenThreads),
145 ],
146 [
147 'flattenThreadsQuote',
148 new FlattenThreadsQuoteHandler(flattenThreads),
149 ],
150 [
151 'flattenThreadsReaddReplyBtn',
152 new FlattenThreadsReaddReplyBtnHandler(flattenThreads),
153 ],
154 [
155 'flattenThreadsReplyBtn',
156 new FlattenThreadsReplyBtnHandler(flattenThreads),
157 ],
158 [
Adrià Vilanova Martínez4e847f42024-11-09 23:03:32 +0100159 'threadPageDesignWarningInject',
160 new ThreadPageDesignWarningInjectHandler(threadPageDesignWarning),
161 ],
162 [
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200163 'workflowsImportCRTags',
164 new WorkflowsImportCRTagsHandler(workflowsImport),
165 ],
166 [
167 'workflowsThreadListActionBar',
168 new WorkflowsThreadListActionBarHandler(new Workflows()),
169 ],
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200170 ]),
171 ),
172
173 // Individual feature scripts
174 new AutoRefreshStylesScript(),
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100175 new CCExtraInfoInjectScript(),
176 new CCExtraInfoStylesScript(),
Adrià Vilanova Martínez3c13a762024-11-09 23:03:32 +0100177 new FlattenThreadsStylesScript(),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200178 new WorkflowsImportStylesheetScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200179
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +0100180 // Standalone scripts
181 new ApplyStartupDataModificationsOnMainScript(startupDataStorage),
182 new InjectLitComponentsScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200183 ],
184 new ScriptSorterAdapter(),
185 ).getScripts(),
186 );
187}