blob: 02003947ee699686295c75f589bbfb4a3c25b1be [file] [log] [blame]
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +02001import {injectScript, injectStyles, injectStylesheet} from '../../common/contentScriptsUtils.js';
Adrià Vilanova Martínez4d599252023-02-04 20:54:54 +01002import {getOptions} from '../../common/optionsUtils.js';
Adrià Vilanova Martínez825888a2023-07-23 01:53:48 +02003import XHRProxyKillSwitchHandler from '../../xhrInterceptor/killSwitchHandler.js';
Adrià Vilanova Martínez1f652522021-10-14 00:23:23 +02004import {injectPreviousPostsLinksUnifiedProfileIfEnabled} from '../utilsCommon/unifiedProfiles.js';
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +02005
Adrià Vilanova Martínez27c69962021-07-17 23:32:51 +02006import AvatarsHandler from './avatars.js';
Adrià Vilanova Martínez462280f2021-08-07 22:59:02 +02007import {batchLock} from './batchLock.js';
Adrià Vilanova Martínez968e93c2024-03-11 23:18:16 +01008import {injectDarkThemeButton, isDarkThemeOn} from './darkTheme/darkTheme.js';
Adrià Vilanova Martínezf472d492024-03-05 21:26:53 +01009import ReportDialogColorThemeFix from './darkTheme/reportDialog.js';
Adrià Vilanova Martínez968e93c2024-03-11 23:18:16 +010010import {unifiedProfilesFix} from './darkTheme/unifiedProfiles.js';
Adrià Vilanova Martínezeebc0ac2022-01-05 14:45:53 +010011// #!if ['chromium', 'chromium_mv3'].includes(browser_target)
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +020012import {applyDragAndDropFixIfEnabled} from './dragAndDropFix.js';
Adrià Vilanova Martínezeebc0ac2022-01-05 14:45:53 +010013// #!endif
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +010014import {default as FlattenThreads, kMatchingSelectors as kFlattenThreadMatchingSelectors} from './flattenThreads/flattenThreads.js';
Adrià Vilanova Martíneza7ae3db2022-01-28 11:57:27 +010015import InfiniteScroll from './infiniteScroll.js';
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +010016import {kRepliesSectionSelector} from './threadToolbar/constants.js';
17import ThreadToolbar from './threadToolbar/threadToolbar.js';
Adrià Vilanova Martínez2788d122022-10-10 22:06:25 +020018import Workflows from './workflows/workflows.js';
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020019
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +010020var mutationObserver, options, avatars, infiniteScroll, workflows,
Adrià Vilanova Martínezf472d492024-03-05 21:26:53 +010021 threadToolbar, flattenThreads, reportDialogColorThemeFix;
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020022
23const watchedNodesSelectors = [
24 // App container (used to set up the intersection observer and inject the dark
25 // mode button)
26 'ec-app',
27
Adrià Vilanova Martíneza7ae3db2022-01-28 11:57:27 +010028 // Scrollable content (used for the intersection observer)
29 '.scrollable-content',
30
31 // Load more bar and buttons
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020032 '.load-more-bar',
Adrià Vilanova Martíneza7ae3db2022-01-28 11:57:27 +010033 '.scTailwindThreadMorebuttonbutton',
Adrià Vilanova Martínez88854972022-08-28 11:57:12 +020034 '.scTailwindThreadMessagegapbutton',
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020035
Adrià Vilanova Martínez7e8796c2022-01-23 21:46:46 +010036 // User profile card inside ec-unified-user
37 'ec-unified-user .scTailwindUser_profileUsercardmain',
38
Adrià Vilanova Martínez531cd072021-12-05 20:15:43 +010039 // Username span/editor inside ec-unified-user (user profile view)
Adrià Vilanova Martínez1f652522021-10-14 00:23:23 +020040 'ec-unified-user .scTailwindUser_profileUsercarddetails',
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020041
42 // Rich text editor
43 'ec-movable-dialog',
44 'ec-rich-text-editor',
45
46 // Read/unread bulk action in the list of thread, for the batch lock feature
47 'ec-bulk-actions material-button[debugid="mark-read-button"]',
48 'ec-bulk-actions material-button[debugid="mark-unread-button"]',
49
Adrià Vilanova Martínez854cb912022-02-02 16:18:23 +010050 // Thread list items (used to inject the avatars and extra info)
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020051 'li',
52
Adrià Vilanova Martínez854cb912022-02-02 16:18:23 +010053 // Thread list item toolbelt (used for the extra info feature)
54 'ec-thread-summary .main .toolbelt',
55
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020056 // Thread list (used for the autorefresh feature)
57 'ec-thread-list',
58
Adrià Vilanova Martínezf472d492024-03-05 21:26:53 +010059 // Unified profile iframe and report dialog iframe
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020060 'iframe',
Adrià Vilanova Martínez74a25202022-01-23 23:36:58 +010061
Adrià Vilanova Martínez46ecb982024-01-30 22:02:17 +010062 // Canned response tags (for the "import CR" popup for the workflows feature)
Adrià Vilanova Martínez6e4a68d2022-01-24 21:44:32 +010063 'ec-canned-response-row .tags',
Adrià Vilanova Martínez6e4a68d2022-01-24 21:44:32 +010064
Adrià Vilanova Martínez09b3bdb2022-02-05 00:15:05 +010065 // Question state chips container (for the extra info feature)
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010066 'sc-tailwind-thread-question-question-card sc-tailwind-thread-question-state-chips',
Adrià Vilanova Martínez6e4a68d2022-01-24 21:44:32 +010067
68 // Replies (for the extra info feature)
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010069 'sc-tailwind-thread-message-message-list sc-tailwind-thread-message-message-card',
Adrià Vilanova Martínez4f56d562022-01-26 00:23:27 +010070
Adrià Vilanova Martínez80f1c732023-11-16 00:52:56 +010071 // Comments (for the extra info feature)
72 'sc-tailwind-thread-message-message-list sc-tailwind-thread-message-comment-card',
73
Adrià Vilanova Martínez4f56d562022-01-26 00:23:27 +010074 // User activity chart (for the per-forum stats feature)
75 'ec-unified-user .scTailwindUser_profileUserprofilesection ' +
76 'sc-tailwind-shared-activity-chart',
Adrià Vilanova Martínez5a8055b2022-09-29 13:05:19 +020077
78 // Thread page main content
79 'ec-thread > .page > .material-content > div[role="list"]',
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +010080
81 // Thread page reply section (for the thread page toolbar)
82 kRepliesSectionSelector,
Adrià Vilanova Martínez412b7582022-12-30 01:35:30 +010083
84 // Reply payload (for the flatten threads UI)
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +010085 ...kFlattenThreadMatchingSelectors,
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020086];
87
88function handleCandidateNode(node) {
89 if (typeof node.classList !== 'undefined') {
90 if (('tagName' in node) && node.tagName == 'EC-APP') {
Adrià Vilanova Martíneza7ae3db2022-01-28 11:57:27 +010091 infiniteScroll.setUpIntersectionObserver(node, false);
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020092
93 // Inject the dark mode button
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +020094 // TODO(avm99963): make this feature dynamic.
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020095 if (options.ccdarktheme && options.ccdarktheme_mode == 'switch') {
96 var rightControl = node.querySelector('header .right-control');
97 if (rightControl !== null)
Adrià Vilanova Martínez968e93c2024-03-11 23:18:16 +010098 injectDarkThemeButton(
99 rightControl, options.ccdarktheme_switch_status);
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200100 }
101 }
102
Adrià Vilanova Martíneza7ae3db2022-01-28 11:57:27 +0100103 // To set up infinite scroll
104 if (node.classList.contains('scrollable-content')) {
105 infiniteScroll.setUpIntersectionObserver(node, true);
106 }
107
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200108 // Start the intersectionObserver for the "load more"/"load all" buttons
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200109 // inside a thread if the option is currently enabled.
110 if (node.classList.contains('load-more-bar')) {
Adrià Vilanova Martíneza7ae3db2022-01-28 11:57:27 +0100111 infiniteScroll.observeLoadMoreBar(node);
112 }
Adrià Vilanova Martínez88854972022-08-28 11:57:12 +0200113 if (node.classList.contains('scTailwindThreadMorebuttonbutton') ||
114 node.classList.contains('scTailwindThreadMessagegapbutton')) {
Adrià Vilanova Martíneza7ae3db2022-01-28 11:57:27 +0100115 infiniteScroll.observeLoadMoreInteropBtn(node);
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200116 }
117
Adrià Vilanova Martínez7e8796c2022-01-23 21:46:46 +0100118 // Show additional details in the profile view.
119 if (node.matches('ec-unified-user .scTailwindUser_profileUsercardmain')) {
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +0100120 window.TWPTExtraInfo.injectAbuseChipsAtProfileIfEnabled(node);
Adrià Vilanova Martínez7e8796c2022-01-23 21:46:46 +0100121 }
122
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200123 // Show the "previous posts" links if the option is currently enabled.
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200124 // Here we're selecting the 'ec-user > div' element (unique child)
Adrià Vilanova Martínez1f652522021-10-14 00:23:23 +0200125 if (node.matches(
126 'ec-unified-user .scTailwindUser_profileUsercarddetails')) {
127 injectPreviousPostsLinksUnifiedProfileIfEnabled(
128 /* isCommunityConsole = */ true);
129 }
130
Adrià Vilanova Martínezeebc0ac2022-01-05 14:45:53 +0100131 // #!if ['chromium', 'chromium_mv3'].includes(browser_target)
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200132 // Fix the drag&drop issue with the rich text editor if the option is
133 // currently enabled.
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200134 //
135 // We target both tags because in different contexts different
136 // elements containing the text editor get added to the DOM structure.
137 // Sometimes it's a EC-MOVABLE-DIALOG which already contains the
138 // EC-RICH-TEXT-EDITOR, and sometimes it's the EC-RICH-TEXT-EDITOR
139 // directly.
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200140 if (('tagName' in node) &&
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200141 (node.tagName == 'EC-MOVABLE-DIALOG' ||
142 node.tagName == 'EC-RICH-TEXT-EDITOR')) {
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200143 applyDragAndDropFixIfEnabled(node);
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200144 }
Adrià Vilanova Martínezeebc0ac2022-01-05 14:45:53 +0100145 // #!endif
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200146
Adrià Vilanova Martínez2788d122022-10-10 22:06:25 +0200147 // Inject the worflows menu in the thread list if the option is currently
148 // enabled.
149 if (workflows.shouldAddThreadListBtn(node)) {
150 workflows.addThreadListBtnIfEnabled(node);
151 }
152
Adrià Vilanova Martínezb06c13d2022-06-20 17:30:14 +0000153 // Inject the batch lock button in the thread list if the option is
154 // currently enabled.
Adrià Vilanova Martínez4107b5e2022-10-09 23:11:11 +0200155 if (batchLock.shouldAddButton(node)) {
Adrià Vilanova Martínezb06c13d2022-06-20 17:30:14 +0000156 batchLock.addButtonIfEnabled(node);
157 }
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200158
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200159 // Inject avatar links to threads in the thread list. injectIfEnabled is
160 // responsible of determining whether it should run or not depending on its
161 // current setting.
Adrià Vilanova Martínez854cb912022-02-02 16:18:23 +0100162 //
163 // Also, inject extra info in the thread list.
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200164 if (('tagName' in node) && (node.tagName == 'LI') &&
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200165 node.querySelector('ec-thread-summary') !== null) {
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200166 avatars.injectIfEnabled(node);
Adrià Vilanova Martínez854cb912022-02-02 16:18:23 +0100167 window.TWPTExtraInfo.injectAtThreadListIfEnabled(node);
168 }
169
170 // Inject extra info in the toolbelt of an expanded thread list item.
171 if (node.matches('ec-thread-summary .main .toolbelt')) {
172 window.TWPTExtraInfo.injectAtExpandedThreadListIfEnabled(node);
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200173 }
174
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200175 // Set up the autorefresh list feature. The setUp function is responsible
176 // of determining whether it should run or not depending on the current
177 // setting.
178 if (('tagName' in node) && node.tagName == 'EC-THREAD-LIST') {
avm99963fd222672021-08-12 23:23:01 +0200179 window.TWPTAutoRefresh.setUp();
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200180 }
181
Adrià Vilanova Martínezf472d492024-03-05 21:26:53 +0100182 if (node.tagName == 'IFRAME') {
183 // Redirect unified profile iframe to dark version if applicable
184 if (isDarkThemeOn(options) && unifiedProfilesFix.checkIframe(node)) {
185 unifiedProfilesFix.fixIframe(node);
186 }
187
188 // Set report dialog iframe's theme to the appropriate theme
189 reportDialogColorThemeFix.fixThemeIfReportDialogIframeAndApplicable(node);
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200190 }
Adrià Vilanova Martínez74a25202022-01-23 23:36:58 +0100191
Adrià Vilanova Martínez46ecb982024-01-30 22:02:17 +0100192 // Add the "import" button in the canned responses view for the workflows
193 // feature if applicable.
Adrià Vilanova Martínez74a25202022-01-23 23:36:58 +0100194 if (node.matches('ec-canned-response-row .tags')) {
Adrià Vilanova Martíneze0d65f22022-11-06 18:49:35 +0100195 window.TWPTWorkflowsImport.addButtonIfEnabled(node);
Adrià Vilanova Martínez74a25202022-01-23 23:36:58 +0100196 }
Adrià Vilanova Martínez6e4a68d2022-01-24 21:44:32 +0100197
198 // Show additional details in the thread view.
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +0100199 if (node.matches(
200 'sc-tailwind-thread-question-question-card sc-tailwind-thread-question-state-chips')) {
Adrià Vilanova Martínez09b3bdb2022-02-05 00:15:05 +0100201 window.TWPTExtraInfo.injectAtQuestionIfEnabled(node);
Adrià Vilanova Martínez6e4a68d2022-01-24 21:44:32 +0100202 }
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +0100203 if (node.matches(
204 'sc-tailwind-thread-message-message-list sc-tailwind-thread-message-message-card')) {
Adrià Vilanova Martínez80f1c732023-11-16 00:52:56 +0100205 window.TWPTExtraInfo.injectAtReplyIfEnabled(node);
206 }
207
208 if (node.matches(
209 'sc-tailwind-thread-message-message-list sc-tailwind-thread-message-comment-card')) {
210 window.TWPTExtraInfo.injectAtCommentIfEnabled(node);
Adrià Vilanova Martínez74a25202022-01-23 23:36:58 +0100211 }
Adrià Vilanova Martínez4f56d562022-01-26 00:23:27 +0100212
213 // Inject per-forum stats section in the user profile
214 if (node.matches(
215 'ec-unified-user .scTailwindUser_profileUserprofilesection ' +
216 'sc-tailwind-shared-activity-chart')) {
217 window.TWPTExtraInfo.injectPerForumStatsIfEnabled(node);
218 }
Adrià Vilanova Martínez5a8055b2022-09-29 13:05:19 +0200219
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +0100220 // Inject old thread page design warning if applicable
Adrià Vilanova Martínezd2344c42022-09-30 13:14:29 +0200221 if (node.matches(
222 'ec-thread > .page > .material-content > div[role="list"]')) {
223 window.TWPTThreadPageDesignWarning.injectWarningIfApplicable(node);
Adrià Vilanova Martínez5a8055b2022-09-29 13:05:19 +0200224 }
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +0100225
226 // Inject thread toolbar
227 if (threadToolbar.shouldInject(node)) {
228 threadToolbar.injectIfApplicable(node);
229 }
Adrià Vilanova Martínez412b7582022-12-30 01:35:30 +0100230
231 // Inject parent reply quote
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +0100232 if (flattenThreads.shouldInjectQuote(node)) {
233 flattenThreads.injectQuoteIfApplicable(node);
234 }
235
236 // Inject reply button in non-nested view
237 if (flattenThreads.shouldInjectReplyBtn(node)) {
238 flattenThreads.injectReplyBtnIfApplicable(node);
Adrià Vilanova Martínez412b7582022-12-30 01:35:30 +0100239 }
Adrià Vilanova Martínez4d599252023-02-04 20:54:54 +0100240
241 // Delete additional info in the edit message box
242 if (flattenThreads.isAdditionalInfoElement(node)) {
243 flattenThreads.deleteAdditionalInfoElementIfApplicable(node);
244 }
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200245 }
246}
247
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +0100248function handleRemovedNode(mutation, node) {
249 if (!('tagName' in node)) return;
250
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200251 // Remove snackbar when exiting thread list view
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +0100252 if (node.tagName == 'EC-THREAD-LIST') {
avm99963fd222672021-08-12 23:23:01 +0200253 window.TWPTAutoRefresh.hideUpdatePrompt();
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200254 }
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +0100255
256 // Readd reply button when the Community Console removes it
257 if (node.tagName == 'TWPT-FLATTEN-THREAD-REPLY-BUTTON') {
258 flattenThreads.injectReplyBtn(
259 mutation.target, JSON.parse(node.getAttribute('extraInfo')));
260 }
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200261}
262
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +0100263function mutationCallback(mutationList) {
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200264 mutationList.forEach((mutation) => {
265 if (mutation.type == 'childList') {
266 mutation.addedNodes.forEach(function(node) {
267 handleCandidateNode(node);
268 });
269
270 mutation.removedNodes.forEach(function(node) {
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +0100271 handleRemovedNode(mutation, node);
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200272 });
273 }
274 });
275}
276
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200277var observerOptions = {
278 childList: true,
279 subtree: true,
280};
281
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200282getOptions(null).then(items => {
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200283 options = items;
284
Adrià Vilanova Martínez27c69962021-07-17 23:32:51 +0200285 // Initialize classes needed by the mutation observer
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200286 avatars = new AvatarsHandler();
Adrià Vilanova Martíneza7ae3db2022-01-28 11:57:27 +0100287 infiniteScroll = new InfiniteScroll();
Adrià Vilanova Martínez2788d122022-10-10 22:06:25 +0200288 workflows = new Workflows();
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +0100289 threadToolbar = new ThreadToolbar();
Adrià Vilanova Martínez412b7582022-12-30 01:35:30 +0100290 flattenThreads = new FlattenThreads();
Adrià Vilanova Martínezf472d492024-03-05 21:26:53 +0100291 reportDialogColorThemeFix = new ReportDialogColorThemeFix(options);
Adrià Vilanova Martínez27c69962021-07-17 23:32:51 +0200292
Adrià Vilanova Martíneze0d65f22022-11-06 18:49:35 +0100293 // autoRefresh, extraInfo, threadPageDesignWarning and workflowsImport are
294 // initialized in start.js
avm99963d3f4ac02021-08-12 18:36:58 +0200295
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200296 // Before starting the mutation Observer, check whether we missed any
297 // mutations by manually checking whether some watched nodes already
298 // exist.
299 var cssSelectors = watchedNodesSelectors.join(',');
300 document.querySelectorAll(cssSelectors)
301 .forEach(node => handleCandidateNode(node));
302
303 mutationObserver = new MutationObserver(mutationCallback);
304 mutationObserver.observe(document.body, observerOptions);
305
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200306 // TODO(avm99963): The following features are not dynamic. Make them be.
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200307 if (options.fixedtoolbar) {
308 injectStyles(
Adrià Vilanovae8ba09a2024-02-29 19:25:39 +0000309 'ec-bulk-actions{position: sticky; top: 0; background: var(--TWPT-primary-background, #fff); z-index: 96;}');
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200310 }
311
312 if (options.increasecontrast) {
313 injectStyles(
314 '.thread-summary.read:not(.checked){background: var(--TWPT-thread-read-background, #ecedee)!important;}');
315 }
316
317 if (options.stickysidebarheaders) {
318 injectStyles(
319 'material-drawer .main-header{background: var(--TWPT-drawer-background, #fff)!important; position: sticky; top: 0; z-index: 1;}');
320 }
321
322 if (options.enhancedannouncementsdot) {
323 injectStylesheet(
324 chrome.runtime.getURL('css/enhanced_announcements_dot.css'));
325 }
326
327 if (options.repositionexpandthread) {
Adrià Vilanova Martínez27c69962021-07-17 23:32:51 +0200328 injectStylesheet(chrome.runtime.getURL('css/reposition_expand_thread.css'));
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200329 }
330
Adrià Vilanova Martínez9d27c212021-12-05 13:54:10 +0100331 if (options.imagemaxheight) {
332 injectStylesheet(chrome.runtime.getURL('css/image_max_height.css'));
333 }
334
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200335 if (options.ccforcehidedrawer) {
336 var drawer = document.querySelector('material-drawer');
337 if (drawer !== null && drawer.classList.contains('mat-drawer-expanded')) {
338 document.querySelector('.material-drawer-button').click();
339 }
340 }
341
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +0200342 // Batch lock
343 injectScript(chrome.runtime.getURL('batchLockInject.bundle.js'));
344 injectStylesheet(chrome.runtime.getURL('css/batchlock_inject.css'));
345 // Thread list avatars
346 injectStylesheet(chrome.runtime.getURL('css/thread_list_avatars.css'));
347 // Auto refresh list
348 injectStylesheet(chrome.runtime.getURL('css/autorefresh_list.css'));
Adrià Vilanova Martínez7e8796c2022-01-23 21:46:46 +0100349 // Extra info
350 injectStylesheet(chrome.runtime.getURL('css/extrainfo.css'));
avm9996337601bc2022-02-21 10:36:45 +0100351 injectStylesheet(chrome.runtime.getURL('css/extrainfo_perforumstats.css'));
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +0100352 // Workflows, Thread toolbar
353 injectScript(chrome.runtime.getURL('litComponentsInject.bundle.js'));
354 // Thread toolbar
355 injectStylesheet(chrome.runtime.getURL('css/thread_toolbar.css'));
Adrià Vilanova Martínez115e3d82023-01-10 21:50:06 +0100356 // Flatten threads
357 injectStylesheet(chrome.runtime.getURL('css/flatten_threads.css'));
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +0200358});
Adrià Vilanova Martínez825888a2023-07-23 01:53:48 +0200359
360new XHRProxyKillSwitchHandler();