Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 1 | // Run legacy Javascript entry point |
| 2 | import '../../../contentScripts/communityConsole/main'; |
| 3 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 4 | import DependenciesProviderSingleton, { |
| 5 | AutoRefreshDependency, |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame] | 6 | ExtraInfoDependency, |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 7 | OptionsProviderDependency, |
Adrià Vilanova Martínez | 33a009c | 2024-11-09 22:41:56 +0100 | [diff] [blame^] | 8 | StartupDataStorageDependency, |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 9 | WorkflowsImportDependency, |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 10 | } from '../../../common/architecture/dependenciesProvider/DependenciesProvider'; |
| 11 | import { Context } from '../../../common/architecture/entrypoint/Context'; |
| 12 | import { |
| 13 | ScriptEnvironment, |
| 14 | ScriptPage, |
| 15 | ScriptRunPhase, |
| 16 | } from '../../../common/architecture/scripts/Script'; |
| 17 | import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler'; |
| 18 | import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler'; |
| 19 | import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script'; |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 20 | import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog'; |
Adrià Vilanova Martínez | fe69478 | 2024-11-09 20:40:43 +0100 | [diff] [blame] | 21 | import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/ecApp.handler'; |
| 22 | import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/reportDialog.handler'; |
| 23 | import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 24 | import Features from '../../../features/Features'; |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 25 | import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 26 | import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter'; |
| 27 | import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter'; |
| 28 | import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner'; |
| 29 | import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter'; |
| 30 | import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter'; |
| 31 | import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler'; |
Adrià Vilanova Martínez | 33a009c | 2024-11-09 22:41:56 +0100 | [diff] [blame^] | 32 | import StandaloneScripts from '../../../presentation/standaloneScripts/Scripts'; |
Adrià Vilanova Martínez | fe69478 | 2024-11-09 20:40:43 +0100 | [diff] [blame] | 33 | import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler'; |
| 34 | import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler'; |
| 35 | import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler'; |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 36 | import WorkflowsThreadListActionBarHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/threadListActionBar.handler'; |
| 37 | import WorkflowsImportCRTagsHandler from '../../../features/workflows/presentation/nodeWatcherHandlers/crTags.handler'; |
| 38 | import Workflows from '../../../features/workflows/core/communityConsole/workflows'; |
| 39 | import WorkflowsImportStylesheetScript from '../../../features/workflows/presentation/scripts/importStylesheet'; |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame] | 40 | import CCExtraInfoProfileAbuseChipsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfileAbuseChips.handler'; |
| 41 | import CCExtraInfoProfilePerForumStatsHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/profile/ccExtraInfoProfilePerForumStats.handler'; |
| 42 | import CCExtraInfoThreadCommentHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadComment.handler'; |
| 43 | import CCExtraInfoThreadListHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadList.handler'; |
| 44 | import CCExtraInfoThreadListToolbeltHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/threadList/ccExtraInfoThreadListToolbelt.handler'; |
| 45 | import CCExtraInfoThreadQuestionHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadQuestion.handler'; |
| 46 | import CCExtraInfoThreadReplyHandler from '../../../features/extraInfo/presentation/nodeWatcherHandlers/thread/ccExtraInfoThreadReply.handler'; |
| 47 | import CCExtraInfoInjectScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoInject.script'; |
| 48 | import CCExtraInfoStylesScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoStyles.script'; |
Adrià Vilanova Martínez | 33a009c | 2024-11-09 22:41:56 +0100 | [diff] [blame^] | 49 | import InjectLitComponentsScript from '../../../presentation/standaloneScripts/litComponents/injectLitComponents.script'; |
| 50 | import ApplyStartupDataModificationsOnMainScript from '../../../presentation/standaloneScripts/startupDataStorage/applyStartupDataModificationsOnMain.script'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 51 | |
| 52 | const scriptRunner = createScriptRunner(); |
| 53 | scriptRunner.run(); |
| 54 | |
| 55 | function createScriptRunner() { |
| 56 | const dependenciesProvider = DependenciesProviderSingleton.getInstance(); |
| 57 | const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency); |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame] | 58 | const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency); |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 59 | const optionsProvider = dependenciesProvider.getDependency( |
| 60 | OptionsProviderDependency, |
| 61 | ); |
Adrià Vilanova Martínez | 33a009c | 2024-11-09 22:41:56 +0100 | [diff] [blame^] | 62 | const startupDataStorage = dependenciesProvider.getDependency( |
| 63 | StartupDataStorageDependency, |
| 64 | ); |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 65 | const workflowsImport = dependenciesProvider.getDependency( |
| 66 | WorkflowsImportDependency, |
| 67 | ); |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 68 | |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 69 | const ccInfiniteScroll = new CCInfiniteScroll(); |
| 70 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 71 | const context: Context = { |
| 72 | page: ScriptPage.CommunityConsole, |
| 73 | environment: ScriptEnvironment.ContentScript, |
| 74 | runPhase: ScriptRunPhase.Main, |
| 75 | }; |
| 76 | |
| 77 | return new ScriptRunner( |
| 78 | new SortedScriptsProviderAdapter( |
| 79 | [ |
| 80 | // Node watcher script with handlers |
| 81 | new NodeWatcherScriptAdapter( |
| 82 | new NodeWatcherAdapter(), |
| 83 | new Map<string, NodeWatcherHandler>([ |
| 84 | [ |
| 85 | 'autoRefreshThreadListSetUp', |
| 86 | new AutoRefreshThreadListSetUpHandler(autoRefresh), |
| 87 | ], |
| 88 | [ |
| 89 | 'autoRefreshThreadListHide', |
| 90 | new AutoRefreshThreadListHideHandler(autoRefresh), |
| 91 | ], |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 92 | ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)], |
| 93 | [ |
| 94 | 'ccDarkThemeReportDialog', |
| 95 | new CCDarkThemeReportDialogHandler( |
| 96 | optionsProvider, |
| 97 | new ReportDialogColorThemeFix(), |
| 98 | ), |
| 99 | ], |
| 100 | [ |
| 101 | 'ccDarkThemeUnifiedProfilesIframe', |
| 102 | new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider), |
| 103 | ], |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 104 | [ |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame] | 105 | 'ccExtraInfoProfile', |
| 106 | new CCExtraInfoProfileAbuseChipsHandler(extraInfo), |
| 107 | ], |
| 108 | [ |
| 109 | 'ccExtraInfoProfilePerForumStats', |
| 110 | new CCExtraInfoProfilePerForumStatsHandler(extraInfo), |
| 111 | ], |
| 112 | [ |
| 113 | 'ccExtraInfoThreadComment', |
| 114 | new CCExtraInfoThreadCommentHandler(extraInfo), |
| 115 | ], |
| 116 | [ |
| 117 | 'ccExtraInfoThreadList', |
| 118 | new CCExtraInfoThreadListHandler(extraInfo), |
| 119 | ], |
| 120 | [ |
| 121 | 'ccExtraInfoThreadListToolbelt', |
| 122 | new CCExtraInfoThreadListToolbeltHandler(extraInfo), |
| 123 | ], |
| 124 | [ |
| 125 | 'ccExtraInfoThreadQuestion', |
| 126 | new CCExtraInfoThreadQuestionHandler(extraInfo), |
| 127 | ], |
| 128 | [ |
| 129 | 'ccExtraInfoThreadReply', |
| 130 | new CCExtraInfoThreadReplyHandler(extraInfo), |
| 131 | ], |
| 132 | [ |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 133 | 'ccInfiniteScrollSetUp', |
| 134 | new CCInfiniteScrollSetUpHandler(ccInfiniteScroll), |
| 135 | ], |
| 136 | [ |
| 137 | 'ccInfiniteScrollLoadMoreBar', |
| 138 | new CCInfiniteScrollLoadMoreBarHandler(ccInfiniteScroll), |
| 139 | ], |
| 140 | [ |
| 141 | 'ccInfiniteScrollLoadMoreBtn', |
| 142 | new CCInfiniteScrollLoadMoreBtnHandler(ccInfiniteScroll), |
| 143 | ], |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 144 | [ |
| 145 | 'workflowsImportCRTags', |
| 146 | new WorkflowsImportCRTagsHandler(workflowsImport), |
| 147 | ], |
| 148 | [ |
| 149 | 'workflowsThreadListActionBar', |
| 150 | new WorkflowsThreadListActionBarHandler(new Workflows()), |
| 151 | ], |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 152 | ]), |
| 153 | ), |
| 154 | |
| 155 | // Individual feature scripts |
| 156 | new AutoRefreshStylesScript(), |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame] | 157 | new CCExtraInfoInjectScript(), |
| 158 | new CCExtraInfoStylesScript(), |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 159 | new WorkflowsImportStylesheetScript(), |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 160 | |
Adrià Vilanova Martínez | 33a009c | 2024-11-09 22:41:56 +0100 | [diff] [blame^] | 161 | // Standalone scripts |
| 162 | new ApplyStartupDataModificationsOnMainScript(startupDataStorage), |
| 163 | new InjectLitComponentsScript(), |
| 164 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 165 | // Non-DI scripts (legacy, should be migrated to use a DI approach) |
| 166 | ...new Features().getScripts(context), |
| 167 | ...new StandaloneScripts().getScripts(context), |
| 168 | ], |
| 169 | new ScriptSorterAdapter(), |
| 170 | ).getScripts(), |
| 171 | ); |
| 172 | } |