blob: 47ec2697b791439a1c521e12937001507381995b [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';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020011import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler';
12import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler';
13import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020014import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010015import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/ecApp.handler';
16import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/reportDialog.handler';
17import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020018import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020019import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
20import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter';
21import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
22import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
23import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
24import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010025import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler';
26import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler';
27import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler';
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020028import WorkflowsThreadListActionBarHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/threadListActionBar.handler';
29import WorkflowsImportCRTagsHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/crTags.handler';
30import Workflows from '../../../features/workflows/core/communityConsole/workflows';
31import WorkflowsImportStylesheetScript from '../../../features/workflows/presentation/scripts/importStylesheet';
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010032import CCExtraInfoProfileAbuseChipsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfileAbuseChips.handler';
33import CCExtraInfoProfilePerForumStatsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfilePerForumStats.handler';
34import CCExtraInfoThreadCommentHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadComment.handler';
35import CCExtraInfoThreadListHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadList.handler';
36import CCExtraInfoThreadListToolbeltHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadListToolbelt.handler';
37import CCExtraInfoThreadQuestionHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadQuestion.handler';
38import CCExtraInfoThreadReplyHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadReply.handler';
39import CCExtraInfoInjectScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoInject.script';
40import CCExtraInfoStylesScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoStyles.script';
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010041import InjectLitComponentsScript from '../../../presentation/standaloneScripts/litComponents/injectLitComponents.script';
42import ApplyStartupDataModificationsOnMainScript from '../../../presentation/standaloneScripts/startupDataStorage/applyStartupDataModificationsOnMain.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020043
44const scriptRunner = createScriptRunner();
45scriptRunner.run();
46
47function createScriptRunner() {
48 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
49 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010050 const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency);
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020051 const optionsProvider = dependenciesProvider.getDependency(
52 OptionsProviderDependency,
53 );
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010054 const startupDataStorage = dependenciesProvider.getDependency(
55 StartupDataStorageDependency,
56 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020057 const workflowsImport = dependenciesProvider.getDependency(
58 WorkflowsImportDependency,
59 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020060
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020061 const ccInfiniteScroll = new CCInfiniteScroll();
62
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020063 return new ScriptRunner(
64 new SortedScriptsProviderAdapter(
65 [
66 // Node watcher script with handlers
67 new NodeWatcherScriptAdapter(
68 new NodeWatcherAdapter(),
69 new Map<string, NodeWatcherHandler>([
70 [
71 'autoRefreshThreadListSetUp',
72 new AutoRefreshThreadListSetUpHandler(autoRefresh),
73 ],
74 [
75 'autoRefreshThreadListHide',
76 new AutoRefreshThreadListHideHandler(autoRefresh),
77 ],
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020078 ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)],
79 [
80 'ccDarkThemeReportDialog',
81 new CCDarkThemeReportDialogHandler(
82 optionsProvider,
83 new ReportDialogColorThemeFix(),
84 ),
85 ],
86 [
87 'ccDarkThemeUnifiedProfilesIframe',
88 new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider),
89 ],
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020090 [
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010091 'ccExtraInfoProfile',
92 new CCExtraInfoProfileAbuseChipsHandler(extraInfo),
93 ],
94 [
95 'ccExtraInfoProfilePerForumStats',
96 new CCExtraInfoProfilePerForumStatsHandler(extraInfo),
97 ],
98 [
99 'ccExtraInfoThreadComment',
100 new CCExtraInfoThreadCommentHandler(extraInfo),
101 ],
102 [
103 'ccExtraInfoThreadList',
104 new CCExtraInfoThreadListHandler(extraInfo),
105 ],
106 [
107 'ccExtraInfoThreadListToolbelt',
108 new CCExtraInfoThreadListToolbeltHandler(extraInfo),
109 ],
110 [
111 'ccExtraInfoThreadQuestion',
112 new CCExtraInfoThreadQuestionHandler(extraInfo),
113 ],
114 [
115 'ccExtraInfoThreadReply',
116 new CCExtraInfoThreadReplyHandler(extraInfo),
117 ],
118 [
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200119 'ccInfiniteScrollSetUp',
120 new CCInfiniteScrollSetUpHandler(ccInfiniteScroll),
121 ],
122 [
123 'ccInfiniteScrollLoadMoreBar',
124 new CCInfiniteScrollLoadMoreBarHandler(ccInfiniteScroll),
125 ],
126 [
127 'ccInfiniteScrollLoadMoreBtn',
128 new CCInfiniteScrollLoadMoreBtnHandler(ccInfiniteScroll),
129 ],
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200130 [
131 'workflowsImportCRTags',
132 new WorkflowsImportCRTagsHandler(workflowsImport),
133 ],
134 [
135 'workflowsThreadListActionBar',
136 new WorkflowsThreadListActionBarHandler(new Workflows()),
137 ],
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200138 ]),
139 ),
140
141 // Individual feature scripts
142 new AutoRefreshStylesScript(),
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100143 new CCExtraInfoInjectScript(),
144 new CCExtraInfoStylesScript(),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200145 new WorkflowsImportStylesheetScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200146
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +0100147 // Standalone scripts
148 new ApplyStartupDataModificationsOnMainScript(startupDataStorage),
149 new InjectLitComponentsScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200150 ],
151 new ScriptSorterAdapter(),
152 ).getScripts(),
153 );
154}