blob: 16bd30f67a58498786d9af152afe91a9093504a8 [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ínez3b585fd2024-11-10 19:17:31 +010051import FixedToolbarStylesScript from '../../../features/fixedToolbar/presentation/scripts/styles.script';
52import EnhancedAnnouncementsDotStylesScript from '../../../features/enhancedAnnouncementsDot/presentation/scripts/styles.script';
53import ImageMaxHeightStylesScript from '../../../features/imageMaxHeight/presentation/scripts/styles.script';
54import RepositionExpandThreadStylesScript from '../../../features/repositionExpandThread/presentation/scripts/styles.script';
55import StickySidebarHeadersStylesScript from '../../../features/stickySidebarHeaders/presentation/scripts/styles.script';
56import IncreaseContrastStylesScript from '../../../features/increaseContrast/presentation/scripts/styles.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020057
58const scriptRunner = createScriptRunner();
59scriptRunner.run();
60
61function createScriptRunner() {
62 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
63 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010064 const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency);
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020065 const optionsProvider = dependenciesProvider.getDependency(
66 OptionsProviderDependency,
67 );
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010068 const startupDataStorage = dependenciesProvider.getDependency(
69 StartupDataStorageDependency,
70 );
Adrià Vilanova Martínez4e847f42024-11-09 23:03:32 +010071 const threadPageDesignWarning = dependenciesProvider.getDependency(
72 ThreadPageDesignWarningDependency,
73 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020074 const workflowsImport = dependenciesProvider.getDependency(
75 WorkflowsImportDependency,
76 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020077
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020078 const ccInfiniteScroll = new CCInfiniteScroll();
Adrià Vilanova Martínez3c13a762024-11-09 23:03:32 +010079 const flattenThreads = new FlattenThreads();
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020080
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020081 return new ScriptRunner(
82 new SortedScriptsProviderAdapter(
83 [
84 // Node watcher script with handlers
85 new NodeWatcherScriptAdapter(
86 new NodeWatcherAdapter(),
87 new Map<string, NodeWatcherHandler>([
88 [
89 'autoRefreshThreadListSetUp',
90 new AutoRefreshThreadListSetUpHandler(autoRefresh),
91 ],
92 [
93 'autoRefreshThreadListHide',
94 new AutoRefreshThreadListHideHandler(autoRefresh),
95 ],
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020096 ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)],
97 [
98 'ccDarkThemeReportDialog',
99 new CCDarkThemeReportDialogHandler(
100 optionsProvider,
101 new ReportDialogColorThemeFix(),
102 ),
103 ],
104 [
105 'ccDarkThemeUnifiedProfilesIframe',
106 new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider),
107 ],
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200108 [
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100109 'ccExtraInfoProfile',
110 new CCExtraInfoProfileAbuseChipsHandler(extraInfo),
111 ],
112 [
113 'ccExtraInfoProfilePerForumStats',
114 new CCExtraInfoProfilePerForumStatsHandler(extraInfo),
115 ],
116 [
117 'ccExtraInfoThreadComment',
118 new CCExtraInfoThreadCommentHandler(extraInfo),
119 ],
120 [
121 'ccExtraInfoThreadList',
122 new CCExtraInfoThreadListHandler(extraInfo),
123 ],
124 [
125 'ccExtraInfoThreadListToolbelt',
126 new CCExtraInfoThreadListToolbeltHandler(extraInfo),
127 ],
128 [
129 'ccExtraInfoThreadQuestion',
130 new CCExtraInfoThreadQuestionHandler(extraInfo),
131 ],
132 [
133 'ccExtraInfoThreadReply',
134 new CCExtraInfoThreadReplyHandler(extraInfo),
135 ],
136 [
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200137 'ccInfiniteScrollSetUp',
138 new CCInfiniteScrollSetUpHandler(ccInfiniteScroll),
139 ],
140 [
141 'ccInfiniteScrollLoadMoreBar',
142 new CCInfiniteScrollLoadMoreBarHandler(ccInfiniteScroll),
143 ],
144 [
145 'ccInfiniteScrollLoadMoreBtn',
146 new CCInfiniteScrollLoadMoreBtnHandler(ccInfiniteScroll),
147 ],
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200148 [
Adrià Vilanova Martínez3c13a762024-11-09 23:03:32 +0100149 'flattenThreadsAdditionalInfo',
150 new FlattenThreadsAdditionalInfoHandler(flattenThreads),
151 ],
152 [
153 'flattenThreadsQuote',
154 new FlattenThreadsQuoteHandler(flattenThreads),
155 ],
156 [
157 'flattenThreadsReaddReplyBtn',
158 new FlattenThreadsReaddReplyBtnHandler(flattenThreads),
159 ],
160 [
161 'flattenThreadsReplyBtn',
162 new FlattenThreadsReplyBtnHandler(flattenThreads),
163 ],
164 [
Adrià Vilanova Martínez4e847f42024-11-09 23:03:32 +0100165 'threadPageDesignWarningInject',
166 new ThreadPageDesignWarningInjectHandler(threadPageDesignWarning),
167 ],
168 [
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200169 'workflowsImportCRTags',
170 new WorkflowsImportCRTagsHandler(workflowsImport),
171 ],
172 [
173 'workflowsThreadListActionBar',
174 new WorkflowsThreadListActionBarHandler(new Workflows()),
175 ],
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200176 ]),
177 ),
178
179 // Individual feature scripts
180 new AutoRefreshStylesScript(),
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100181 new CCExtraInfoInjectScript(),
182 new CCExtraInfoStylesScript(),
Adrià Vilanova Martínez3b585fd2024-11-10 19:17:31 +0100183 new EnhancedAnnouncementsDotStylesScript(),
184 new FixedToolbarStylesScript(),
Adrià Vilanova Martínez3c13a762024-11-09 23:03:32 +0100185 new FlattenThreadsStylesScript(),
Adrià Vilanova Martínez3b585fd2024-11-10 19:17:31 +0100186 new ImageMaxHeightStylesScript(),
187 new IncreaseContrastStylesScript(),
188 new RepositionExpandThreadStylesScript(),
189 new StickySidebarHeadersStylesScript(),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200190 new WorkflowsImportStylesheetScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200191
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +0100192 // Standalone scripts
193 new ApplyStartupDataModificationsOnMainScript(startupDataStorage),
194 new InjectLitComponentsScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200195 ],
196 new ScriptSorterAdapter(),
197 ).getScripts(),
198 );
199}