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