blob: 35088ea28732f1589eab9e263ee0607c9e570a5d [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ínezf92172f2024-10-19 15:55:15 +020045
46const scriptRunner = createScriptRunner();
47scriptRunner.run();
48
49function createScriptRunner() {
50 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
51 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010052 const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency);
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020053 const optionsProvider = dependenciesProvider.getDependency(
54 OptionsProviderDependency,
55 );
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010056 const startupDataStorage = dependenciesProvider.getDependency(
57 StartupDataStorageDependency,
58 );
Adrià Vilanova Martínez4e847f42024-11-09 23:03:32 +010059 const threadPageDesignWarning = dependenciesProvider.getDependency(
60 ThreadPageDesignWarningDependency,
61 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020062 const workflowsImport = dependenciesProvider.getDependency(
63 WorkflowsImportDependency,
64 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020065
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020066 const ccInfiniteScroll = new CCInfiniteScroll();
67
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020068 return new ScriptRunner(
69 new SortedScriptsProviderAdapter(
70 [
71 // Node watcher script with handlers
72 new NodeWatcherScriptAdapter(
73 new NodeWatcherAdapter(),
74 new Map<string, NodeWatcherHandler>([
75 [
76 'autoRefreshThreadListSetUp',
77 new AutoRefreshThreadListSetUpHandler(autoRefresh),
78 ],
79 [
80 'autoRefreshThreadListHide',
81 new AutoRefreshThreadListHideHandler(autoRefresh),
82 ],
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020083 ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)],
84 [
85 'ccDarkThemeReportDialog',
86 new CCDarkThemeReportDialogHandler(
87 optionsProvider,
88 new ReportDialogColorThemeFix(),
89 ),
90 ],
91 [
92 'ccDarkThemeUnifiedProfilesIframe',
93 new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider),
94 ],
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020095 [
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010096 'ccExtraInfoProfile',
97 new CCExtraInfoProfileAbuseChipsHandler(extraInfo),
98 ],
99 [
100 'ccExtraInfoProfilePerForumStats',
101 new CCExtraInfoProfilePerForumStatsHandler(extraInfo),
102 ],
103 [
104 'ccExtraInfoThreadComment',
105 new CCExtraInfoThreadCommentHandler(extraInfo),
106 ],
107 [
108 'ccExtraInfoThreadList',
109 new CCExtraInfoThreadListHandler(extraInfo),
110 ],
111 [
112 'ccExtraInfoThreadListToolbelt',
113 new CCExtraInfoThreadListToolbeltHandler(extraInfo),
114 ],
115 [
116 'ccExtraInfoThreadQuestion',
117 new CCExtraInfoThreadQuestionHandler(extraInfo),
118 ],
119 [
120 'ccExtraInfoThreadReply',
121 new CCExtraInfoThreadReplyHandler(extraInfo),
122 ],
123 [
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +0200124 'ccInfiniteScrollSetUp',
125 new CCInfiniteScrollSetUpHandler(ccInfiniteScroll),
126 ],
127 [
128 'ccInfiniteScrollLoadMoreBar',
129 new CCInfiniteScrollLoadMoreBarHandler(ccInfiniteScroll),
130 ],
131 [
132 'ccInfiniteScrollLoadMoreBtn',
133 new CCInfiniteScrollLoadMoreBtnHandler(ccInfiniteScroll),
134 ],
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200135 [
Adrià Vilanova Martínez4e847f42024-11-09 23:03:32 +0100136 'threadPageDesignWarningInject',
137 new ThreadPageDesignWarningInjectHandler(threadPageDesignWarning),
138 ],
139 [
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200140 'workflowsImportCRTags',
141 new WorkflowsImportCRTagsHandler(workflowsImport),
142 ],
143 [
144 'workflowsThreadListActionBar',
145 new WorkflowsThreadListActionBarHandler(new Workflows()),
146 ],
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200147 ]),
148 ),
149
150 // Individual feature scripts
151 new AutoRefreshStylesScript(),
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +0100152 new CCExtraInfoInjectScript(),
153 new CCExtraInfoStylesScript(),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +0200154 new WorkflowsImportStylesheetScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200155
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +0100156 // Standalone scripts
157 new ApplyStartupDataModificationsOnMainScript(startupDataStorage),
158 new InjectLitComponentsScript(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +0200159 ],
160 new ScriptSorterAdapter(),
161 ).getScripts(),
162 );
163}