Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 1 | import {injectScript, injectStyles, injectStylesheet} from '../../common/contentScriptsUtils.js'; |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 2 | import {getOptions, isOptionEnabled} from '../../common/optionsUtils.js'; |
Adrià Vilanova Martínez | 1f65252 | 2021-10-14 00:23:23 +0200 | [diff] [blame] | 3 | import {injectPreviousPostsLinksUnifiedProfileIfEnabled} from '../utilsCommon/unifiedProfiles.js'; |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 4 | |
Adrià Vilanova Martínez | 27c6996 | 2021-07-17 23:32:51 +0200 | [diff] [blame] | 5 | import AvatarsHandler from './avatars.js'; |
Adrià Vilanova Martínez | 462280f | 2021-08-07 22:59:02 +0200 | [diff] [blame] | 6 | import {batchLock} from './batchLock.js'; |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 7 | import {injectDarkModeButton, isDarkThemeOn} from './darkMode.js'; |
Adrià Vilanova Martínez | eebc0ac | 2022-01-05 14:45:53 +0100 | [diff] [blame] | 8 | // #!if ['chromium', 'chromium_mv3'].includes(browser_target) |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 9 | import {applyDragAndDropFixIfEnabled} from './dragAndDropFix.js'; |
Adrià Vilanova Martínez | eebc0ac | 2022-01-05 14:45:53 +0100 | [diff] [blame] | 10 | // #!endif |
Adrià Vilanova Martínez | a7ae3db | 2022-01-28 11:57:27 +0100 | [diff] [blame] | 11 | import InfiniteScroll from './infiniteScroll.js'; |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 12 | import {unifiedProfilesFix} from './unifiedProfiles.js'; |
Adrià Vilanova Martínez | 2788d12 | 2022-10-10 22:06:25 +0200 | [diff] [blame] | 13 | import Workflows from './workflows/workflows.js'; |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 14 | |
Adrià Vilanova Martínez | 2788d12 | 2022-10-10 22:06:25 +0200 | [diff] [blame] | 15 | var mutationObserver, options, avatars, infiniteScroll, workflows; |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 16 | |
| 17 | const watchedNodesSelectors = [ |
| 18 | // App container (used to set up the intersection observer and inject the dark |
| 19 | // mode button) |
| 20 | 'ec-app', |
| 21 | |
Adrià Vilanova Martínez | a7ae3db | 2022-01-28 11:57:27 +0100 | [diff] [blame] | 22 | // Scrollable content (used for the intersection observer) |
| 23 | '.scrollable-content', |
| 24 | |
| 25 | // Load more bar and buttons |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 26 | '.load-more-bar', |
Adrià Vilanova Martínez | a7ae3db | 2022-01-28 11:57:27 +0100 | [diff] [blame] | 27 | '.scTailwindThreadMorebuttonbutton', |
Adrià Vilanova Martínez | 8885497 | 2022-08-28 11:57:12 +0200 | [diff] [blame] | 28 | '.scTailwindThreadMessagegapbutton', |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 29 | |
Adrià Vilanova Martínez | 7e8796c | 2022-01-23 21:46:46 +0100 | [diff] [blame] | 30 | // User profile card inside ec-unified-user |
| 31 | 'ec-unified-user .scTailwindUser_profileUsercardmain', |
| 32 | |
Adrià Vilanova Martínez | 531cd07 | 2021-12-05 20:15:43 +0100 | [diff] [blame] | 33 | // Username span/editor inside ec-unified-user (user profile view) |
Adrià Vilanova Martínez | 1f65252 | 2021-10-14 00:23:23 +0200 | [diff] [blame] | 34 | 'ec-unified-user .scTailwindUser_profileUsercarddetails', |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 35 | |
| 36 | // Rich text editor |
| 37 | 'ec-movable-dialog', |
| 38 | 'ec-rich-text-editor', |
| 39 | |
| 40 | // Read/unread bulk action in the list of thread, for the batch lock feature |
| 41 | 'ec-bulk-actions material-button[debugid="mark-read-button"]', |
| 42 | 'ec-bulk-actions material-button[debugid="mark-unread-button"]', |
| 43 | |
Adrià Vilanova Martínez | 854cb91 | 2022-02-02 16:18:23 +0100 | [diff] [blame] | 44 | // Thread list items (used to inject the avatars and extra info) |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 45 | 'li', |
| 46 | |
Adrià Vilanova Martínez | 854cb91 | 2022-02-02 16:18:23 +0100 | [diff] [blame] | 47 | // Thread list item toolbelt (used for the extra info feature) |
| 48 | 'ec-thread-summary .main .toolbelt', |
| 49 | |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 50 | // Thread list (used for the autorefresh feature) |
| 51 | 'ec-thread-list', |
| 52 | |
| 53 | // Unified profile iframe |
| 54 | 'iframe', |
Adrià Vilanova Martínez | 74a2520 | 2022-01-23 23:36:58 +0100 | [diff] [blame] | 55 | |
Adrià Vilanova Martínez | e0d65f2 | 2022-11-06 18:49:35 +0100 | [diff] [blame] | 56 | // Canned response tags or toolbelt (for the extra info feature and the |
| 57 | // "import CR" popup for the workflows feature) |
Adrià Vilanova Martínez | 6e4a68d | 2022-01-24 21:44:32 +0100 | [diff] [blame] | 58 | 'ec-canned-response-row .tags', |
| 59 | 'ec-canned-response-row .main .toolbelt', |
| 60 | |
Adrià Vilanova Martínez | 09b3bdb | 2022-02-05 00:15:05 +0100 | [diff] [blame] | 61 | // Question state chips container (for the extra info feature) |
| 62 | 'ec-question .state-chips', |
Adrià Vilanova Martínez | 6e4a68d | 2022-01-24 21:44:32 +0100 | [diff] [blame] | 63 | |
| 64 | // Replies (for the extra info feature) |
| 65 | 'ec-thread ec-message', |
Adrià Vilanova Martínez | 4f56d56 | 2022-01-26 00:23:27 +0100 | [diff] [blame] | 66 | |
| 67 | // User activity chart (for the per-forum stats feature) |
| 68 | 'ec-unified-user .scTailwindUser_profileUserprofilesection ' + |
| 69 | 'sc-tailwind-shared-activity-chart', |
Adrià Vilanova Martínez | 5a8055b | 2022-09-29 13:05:19 +0200 | [diff] [blame] | 70 | |
| 71 | // Thread page main content |
| 72 | 'ec-thread > .page > .material-content > div[role="list"]', |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 73 | ]; |
| 74 | |
| 75 | function handleCandidateNode(node) { |
| 76 | if (typeof node.classList !== 'undefined') { |
| 77 | if (('tagName' in node) && node.tagName == 'EC-APP') { |
Adrià Vilanova Martínez | a7ae3db | 2022-01-28 11:57:27 +0100 | [diff] [blame] | 78 | infiniteScroll.setUpIntersectionObserver(node, false); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 79 | |
| 80 | // Inject the dark mode button |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 81 | // TODO(avm99963): make this feature dynamic. |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 82 | if (options.ccdarktheme && options.ccdarktheme_mode == 'switch') { |
| 83 | var rightControl = node.querySelector('header .right-control'); |
| 84 | if (rightControl !== null) |
| 85 | injectDarkModeButton(rightControl, options.ccdarktheme_switch_status); |
| 86 | } |
| 87 | } |
| 88 | |
Adrià Vilanova Martínez | a7ae3db | 2022-01-28 11:57:27 +0100 | [diff] [blame] | 89 | // To set up infinite scroll |
| 90 | if (node.classList.contains('scrollable-content')) { |
| 91 | infiniteScroll.setUpIntersectionObserver(node, true); |
| 92 | } |
| 93 | |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 94 | // Start the intersectionObserver for the "load more"/"load all" buttons |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 95 | // inside a thread if the option is currently enabled. |
| 96 | if (node.classList.contains('load-more-bar')) { |
Adrià Vilanova Martínez | a7ae3db | 2022-01-28 11:57:27 +0100 | [diff] [blame] | 97 | infiniteScroll.observeLoadMoreBar(node); |
| 98 | } |
Adrià Vilanova Martínez | 8885497 | 2022-08-28 11:57:12 +0200 | [diff] [blame] | 99 | if (node.classList.contains('scTailwindThreadMorebuttonbutton') || |
| 100 | node.classList.contains('scTailwindThreadMessagegapbutton')) { |
Adrià Vilanova Martínez | a7ae3db | 2022-01-28 11:57:27 +0100 | [diff] [blame] | 101 | infiniteScroll.observeLoadMoreInteropBtn(node); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 102 | } |
| 103 | |
Adrià Vilanova Martínez | 7e8796c | 2022-01-23 21:46:46 +0100 | [diff] [blame] | 104 | // Show additional details in the profile view. |
| 105 | if (node.matches('ec-unified-user .scTailwindUser_profileUsercardmain')) { |
| 106 | window.TWPTExtraInfo.injectAtProfileIfEnabled(node); |
| 107 | } |
| 108 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 109 | // Show the "previous posts" links if the option is currently enabled. |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 110 | // Here we're selecting the 'ec-user > div' element (unique child) |
Adrià Vilanova Martínez | 1f65252 | 2021-10-14 00:23:23 +0200 | [diff] [blame] | 111 | if (node.matches( |
| 112 | 'ec-unified-user .scTailwindUser_profileUsercarddetails')) { |
| 113 | injectPreviousPostsLinksUnifiedProfileIfEnabled( |
| 114 | /* isCommunityConsole = */ true); |
| 115 | } |
| 116 | |
Adrià Vilanova Martínez | eebc0ac | 2022-01-05 14:45:53 +0100 | [diff] [blame] | 117 | // #!if ['chromium', 'chromium_mv3'].includes(browser_target) |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 118 | // Fix the drag&drop issue with the rich text editor if the option is |
| 119 | // currently enabled. |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 120 | // |
| 121 | // We target both tags because in different contexts different |
| 122 | // elements containing the text editor get added to the DOM structure. |
| 123 | // Sometimes it's a EC-MOVABLE-DIALOG which already contains the |
| 124 | // EC-RICH-TEXT-EDITOR, and sometimes it's the EC-RICH-TEXT-EDITOR |
| 125 | // directly. |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 126 | if (('tagName' in node) && |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 127 | (node.tagName == 'EC-MOVABLE-DIALOG' || |
| 128 | node.tagName == 'EC-RICH-TEXT-EDITOR')) { |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 129 | applyDragAndDropFixIfEnabled(node); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 130 | } |
Adrià Vilanova Martínez | eebc0ac | 2022-01-05 14:45:53 +0100 | [diff] [blame] | 131 | // #!endif |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 132 | |
Adrià Vilanova Martínez | 2788d12 | 2022-10-10 22:06:25 +0200 | [diff] [blame] | 133 | // Inject the worflows menu in the thread list if the option is currently |
| 134 | // enabled. |
| 135 | if (workflows.shouldAddThreadListBtn(node)) { |
| 136 | workflows.addThreadListBtnIfEnabled(node); |
| 137 | } |
| 138 | |
Adrià Vilanova Martínez | b06c13d | 2022-06-20 17:30:14 +0000 | [diff] [blame] | 139 | // Inject the batch lock button in the thread list if the option is |
| 140 | // currently enabled. |
Adrià Vilanova Martínez | 4107b5e | 2022-10-09 23:11:11 +0200 | [diff] [blame] | 141 | if (batchLock.shouldAddButton(node)) { |
Adrià Vilanova Martínez | b06c13d | 2022-06-20 17:30:14 +0000 | [diff] [blame] | 142 | batchLock.addButtonIfEnabled(node); |
| 143 | } |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 144 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 145 | // Inject avatar links to threads in the thread list. injectIfEnabled is |
| 146 | // responsible of determining whether it should run or not depending on its |
| 147 | // current setting. |
Adrià Vilanova Martínez | 854cb91 | 2022-02-02 16:18:23 +0100 | [diff] [blame] | 148 | // |
| 149 | // Also, inject extra info in the thread list. |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 150 | if (('tagName' in node) && (node.tagName == 'LI') && |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 151 | node.querySelector('ec-thread-summary') !== null) { |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 152 | avatars.injectIfEnabled(node); |
Adrià Vilanova Martínez | 854cb91 | 2022-02-02 16:18:23 +0100 | [diff] [blame] | 153 | window.TWPTExtraInfo.injectAtThreadListIfEnabled(node); |
| 154 | } |
| 155 | |
| 156 | // Inject extra info in the toolbelt of an expanded thread list item. |
| 157 | if (node.matches('ec-thread-summary .main .toolbelt')) { |
| 158 | window.TWPTExtraInfo.injectAtExpandedThreadListIfEnabled(node); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 159 | } |
| 160 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 161 | // Set up the autorefresh list feature. The setUp function is responsible |
| 162 | // of determining whether it should run or not depending on the current |
| 163 | // setting. |
| 164 | if (('tagName' in node) && node.tagName == 'EC-THREAD-LIST') { |
avm99963 | fd22267 | 2021-08-12 23:23:01 +0200 | [diff] [blame] | 165 | window.TWPTAutoRefresh.setUp(); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | // Redirect unified profile iframe to dark version if applicable |
| 169 | if (node.tagName == 'IFRAME' && isDarkThemeOn(options) && |
| 170 | unifiedProfilesFix.checkIframe(node)) { |
| 171 | unifiedProfilesFix.fixIframe(node); |
| 172 | } |
Adrià Vilanova Martínez | 74a2520 | 2022-01-23 23:36:58 +0100 | [diff] [blame] | 173 | |
Adrià Vilanova Martínez | e0d65f2 | 2022-11-06 18:49:35 +0100 | [diff] [blame] | 174 | // Show additional details in the canned responses view (and add the |
| 175 | // "import" button if applicable for the workflows feature). |
Adrià Vilanova Martínez | 74a2520 | 2022-01-23 23:36:58 +0100 | [diff] [blame] | 176 | if (node.matches('ec-canned-response-row .tags')) { |
| 177 | window.TWPTExtraInfo.injectAtCRIfEnabled(node, /* isExpanded = */ false); |
Adrià Vilanova Martínez | e0d65f2 | 2022-11-06 18:49:35 +0100 | [diff] [blame] | 178 | window.TWPTWorkflowsImport.addButtonIfEnabled(node); |
Adrià Vilanova Martínez | 74a2520 | 2022-01-23 23:36:58 +0100 | [diff] [blame] | 179 | } |
| 180 | if (node.matches('ec-canned-response-row .main .toolbelt')) { |
| 181 | const tags = node.parentNode?.querySelector?.('.tags'); |
Adrià Vilanova Martínez | 6e4a68d | 2022-01-24 21:44:32 +0100 | [diff] [blame] | 182 | if (tags) |
| 183 | window.TWPTExtraInfo.injectAtCRIfEnabled(tags, /* isExpanded = */ true); |
| 184 | } |
| 185 | |
| 186 | // Show additional details in the thread view. |
Adrià Vilanova Martínez | 09b3bdb | 2022-02-05 00:15:05 +0100 | [diff] [blame] | 187 | if (node.matches('ec-question .state-chips')) { |
| 188 | window.TWPTExtraInfo.injectAtQuestionIfEnabled(node); |
Adrià Vilanova Martínez | 6e4a68d | 2022-01-24 21:44:32 +0100 | [diff] [blame] | 189 | } |
| 190 | if (node.matches('ec-thread ec-message')) { |
| 191 | window.TWPTExtraInfo.injectAtMessageIfEnabled(node); |
Adrià Vilanova Martínez | 74a2520 | 2022-01-23 23:36:58 +0100 | [diff] [blame] | 192 | } |
Adrià Vilanova Martínez | 4f56d56 | 2022-01-26 00:23:27 +0100 | [diff] [blame] | 193 | |
| 194 | // Inject per-forum stats section in the user profile |
| 195 | if (node.matches( |
| 196 | 'ec-unified-user .scTailwindUser_profileUserprofilesection ' + |
| 197 | 'sc-tailwind-shared-activity-chart')) { |
| 198 | window.TWPTExtraInfo.injectPerForumStatsIfEnabled(node); |
| 199 | } |
Adrià Vilanova Martínez | 5a8055b | 2022-09-29 13:05:19 +0200 | [diff] [blame] | 200 | |
Adrià Vilanova Martínez | d2344c4 | 2022-09-30 13:14:29 +0200 | [diff] [blame] | 201 | if (node.matches( |
| 202 | 'ec-thread > .page > .material-content > div[role="list"]')) { |
| 203 | window.TWPTThreadPageDesignWarning.injectWarningIfApplicable(node); |
Adrià Vilanova Martínez | 5a8055b | 2022-09-29 13:05:19 +0200 | [diff] [blame] | 204 | } |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
| 208 | function handleRemovedNode(node) { |
| 209 | // Remove snackbar when exiting thread list view |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 210 | if ('tagName' in node && node.tagName == 'EC-THREAD-LIST') { |
avm99963 | fd22267 | 2021-08-12 23:23:01 +0200 | [diff] [blame] | 211 | window.TWPTAutoRefresh.hideUpdatePrompt(); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | |
| 215 | function mutationCallback(mutationList, observer) { |
| 216 | mutationList.forEach((mutation) => { |
| 217 | if (mutation.type == 'childList') { |
| 218 | mutation.addedNodes.forEach(function(node) { |
| 219 | handleCandidateNode(node); |
| 220 | }); |
| 221 | |
| 222 | mutation.removedNodes.forEach(function(node) { |
| 223 | handleRemovedNode(node); |
| 224 | }); |
| 225 | } |
| 226 | }); |
| 227 | } |
| 228 | |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 229 | var observerOptions = { |
| 230 | childList: true, |
| 231 | subtree: true, |
| 232 | }; |
| 233 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 234 | getOptions(null).then(items => { |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 235 | options = items; |
| 236 | |
Adrià Vilanova Martínez | 27c6996 | 2021-07-17 23:32:51 +0200 | [diff] [blame] | 237 | // Initialize classes needed by the mutation observer |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 238 | avatars = new AvatarsHandler(); |
Adrià Vilanova Martínez | a7ae3db | 2022-01-28 11:57:27 +0100 | [diff] [blame] | 239 | infiniteScroll = new InfiniteScroll(); |
Adrià Vilanova Martínez | 2788d12 | 2022-10-10 22:06:25 +0200 | [diff] [blame] | 240 | workflows = new Workflows(); |
Adrià Vilanova Martínez | 27c6996 | 2021-07-17 23:32:51 +0200 | [diff] [blame] | 241 | |
Adrià Vilanova Martínez | e0d65f2 | 2022-11-06 18:49:35 +0100 | [diff] [blame] | 242 | // autoRefresh, extraInfo, threadPageDesignWarning and workflowsImport are |
| 243 | // initialized in start.js |
avm99963 | d3f4ac0 | 2021-08-12 18:36:58 +0200 | [diff] [blame] | 244 | |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 245 | // Before starting the mutation Observer, check whether we missed any |
| 246 | // mutations by manually checking whether some watched nodes already |
| 247 | // exist. |
| 248 | var cssSelectors = watchedNodesSelectors.join(','); |
| 249 | document.querySelectorAll(cssSelectors) |
| 250 | .forEach(node => handleCandidateNode(node)); |
| 251 | |
| 252 | mutationObserver = new MutationObserver(mutationCallback); |
| 253 | mutationObserver.observe(document.body, observerOptions); |
| 254 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 255 | // TODO(avm99963): The following features are not dynamic. Make them be. |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 256 | if (options.fixedtoolbar) { |
| 257 | injectStyles( |
| 258 | 'ec-bulk-actions{position: sticky; top: 0; background: var(--TWPT-primary-background, #fff); z-index: 96;}'); |
| 259 | } |
| 260 | |
| 261 | if (options.increasecontrast) { |
| 262 | injectStyles( |
| 263 | '.thread-summary.read:not(.checked){background: var(--TWPT-thread-read-background, #ecedee)!important;}'); |
| 264 | } |
| 265 | |
| 266 | if (options.stickysidebarheaders) { |
| 267 | injectStyles( |
| 268 | 'material-drawer .main-header{background: var(--TWPT-drawer-background, #fff)!important; position: sticky; top: 0; z-index: 1;}'); |
| 269 | } |
| 270 | |
| 271 | if (options.enhancedannouncementsdot) { |
| 272 | injectStylesheet( |
| 273 | chrome.runtime.getURL('css/enhanced_announcements_dot.css')); |
| 274 | } |
| 275 | |
| 276 | if (options.repositionexpandthread) { |
Adrià Vilanova Martínez | 27c6996 | 2021-07-17 23:32:51 +0200 | [diff] [blame] | 277 | injectStylesheet(chrome.runtime.getURL('css/reposition_expand_thread.css')); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 278 | } |
| 279 | |
Adrià Vilanova Martínez | 9d27c21 | 2021-12-05 13:54:10 +0100 | [diff] [blame] | 280 | if (options.imagemaxheight) { |
| 281 | injectStylesheet(chrome.runtime.getURL('css/image_max_height.css')); |
| 282 | } |
| 283 | |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 284 | if (options.ccforcehidedrawer) { |
| 285 | var drawer = document.querySelector('material-drawer'); |
| 286 | if (drawer !== null && drawer.classList.contains('mat-drawer-expanded')) { |
| 287 | document.querySelector('.material-drawer-button').click(); |
| 288 | } |
| 289 | } |
| 290 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 291 | // Batch lock |
| 292 | injectScript(chrome.runtime.getURL('batchLockInject.bundle.js')); |
| 293 | injectStylesheet(chrome.runtime.getURL('css/batchlock_inject.css')); |
| 294 | // Thread list avatars |
| 295 | injectStylesheet(chrome.runtime.getURL('css/thread_list_avatars.css')); |
| 296 | // Auto refresh list |
| 297 | injectStylesheet(chrome.runtime.getURL('css/autorefresh_list.css')); |
Adrià Vilanova Martínez | 7e8796c | 2022-01-23 21:46:46 +0100 | [diff] [blame] | 298 | // Extra info |
| 299 | injectStylesheet(chrome.runtime.getURL('css/extrainfo.css')); |
avm99963 | 37601bc | 2022-02-21 10:36:45 +0100 | [diff] [blame] | 300 | injectStylesheet(chrome.runtime.getURL('css/extrainfo_perforumstats.css')); |
Adrià Vilanova Martínez | 2788d12 | 2022-10-10 22:06:25 +0200 | [diff] [blame] | 301 | // Workflows |
| 302 | injectScript(chrome.runtime.getURL('workflowComponentsInject.bundle.js')); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 303 | }); |