avm99963 | 1170703 | 2021-02-05 19:11:25 +0100 | [diff] [blame] | 1 | var mutationObserver, intersectionObserver, intersectionOptions, options, |
| 2 | authuser; |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 3 | |
avm99963 | f592396 | 2020-12-07 16:44:37 +0100 | [diff] [blame] | 4 | function removeChildNodes(node) { |
| 5 | while (node.firstChild) { |
| 6 | node.removeChild(node.firstChild); |
avm99963 | af7860e | 2019-06-04 03:33:26 +0200 | [diff] [blame] | 7 | } |
avm99963 | f592396 | 2020-12-07 16:44:37 +0100 | [diff] [blame] | 8 | } |
avm99963 | af7860e | 2019-06-04 03:33:26 +0200 | [diff] [blame] | 9 | |
avm99963 | 90cc2e3 | 2021-02-05 18:14:16 +0100 | [diff] [blame] | 10 | function getNParent(node, n) { |
| 11 | if (n <= 0) return node; |
| 12 | if (!('parentNode' in node)) return null; |
| 13 | return getNParent(node.parentNode, n - 1); |
| 14 | } |
| 15 | |
avm99963 | f592396 | 2020-12-07 16:44:37 +0100 | [diff] [blame] | 16 | function createExtBadge() { |
| 17 | var badge = document.createElement('div'); |
| 18 | badge.classList.add('TWPT-badge'); |
| 19 | badge.setAttribute( |
| 20 | 'title', chrome.i18n.getMessage('inject_extension_badge_helper', [ |
| 21 | chrome.i18n.getMessage('appName') |
| 22 | ])); |
| 23 | |
| 24 | var badgeI = document.createElement('i'); |
| 25 | badgeI.classList.add('material-icon-i', 'material-icons-extended'); |
| 26 | badgeI.textContent = 'repeat'; |
| 27 | |
| 28 | badge.append(badgeI); |
| 29 | return badge; |
avm99963 | af7860e | 2019-06-04 03:33:26 +0200 | [diff] [blame] | 30 | } |
| 31 | |
avm99963 | 943b849 | 2020-08-31 23:40:43 +0200 | [diff] [blame] | 32 | function addProfileHistoryLink(node, type, query) { |
| 33 | var urlpart = encodeURIComponent('query=' + query); |
avm99963 | a2945b6 | 2020-11-27 00:32:02 +0100 | [diff] [blame] | 34 | var authuserpart = |
| 35 | (authuser == '0' ? '' : '?authuser=' + encodeURIComponent(authuser)); |
avm99963 | 943b849 | 2020-08-31 23:40:43 +0200 | [diff] [blame] | 36 | var container = document.createElement('div'); |
| 37 | container.style.margin = '3px 0'; |
| 38 | |
| 39 | var link = document.createElement('a'); |
| 40 | link.setAttribute( |
avm99963 | a2945b6 | 2020-11-27 00:32:02 +0100 | [diff] [blame] | 41 | 'href', |
| 42 | 'https://support.google.com/s/community/search/' + urlpart + |
| 43 | authuserpart); |
avm99963 | 943b849 | 2020-08-31 23:40:43 +0200 | [diff] [blame] | 44 | link.innerText = chrome.i18n.getMessage('inject_previousposts_' + type); |
| 45 | |
| 46 | container.appendChild(link); |
avm99963 | 0616775 | 2020-09-08 00:50:36 +0200 | [diff] [blame] | 47 | node.appendChild(container); |
avm99963 | 943b849 | 2020-08-31 23:40:43 +0200 | [diff] [blame] | 48 | } |
| 49 | |
avm99963 | 8e0c100 | 2020-12-03 16:54:20 +0100 | [diff] [blame] | 50 | function applyDragAndDropFix(node) { |
| 51 | console.debug('Adding link drag&drop fix to ', node); |
| 52 | node.addEventListener('drop', e => { |
| 53 | if (e.dataTransfer.types.includes('text/uri-list')) { |
| 54 | e.stopImmediatePropagation(); |
| 55 | console.debug('Stopping link drop event propagation.'); |
| 56 | } |
| 57 | }, true); |
| 58 | } |
| 59 | |
avm99963 | f592396 | 2020-12-07 16:44:37 +0100 | [diff] [blame] | 60 | function nodeIsReadToggleBtn(node) { |
| 61 | return ('tagName' in node) && node.tagName == 'MATERIAL-BUTTON' && |
| 62 | node.getAttribute('debugid') !== null && |
| 63 | (node.getAttribute('debugid') == 'mark-read-button' || |
| 64 | node.getAttribute('debugid') == 'mark-unread-button') && |
| 65 | ('parentNode' in node) && node.parentNode !== null && |
| 66 | ('parentNode' in node.parentNode) && |
| 67 | node.parentNode.querySelector('[debugid="batchlock"]') === null && |
| 68 | node.parentNode.parentNode !== null && |
| 69 | ('tagName' in node.parentNode.parentNode) && |
| 70 | node.parentNode.parentNode.tagName == 'EC-BULK-ACTIONS'; |
| 71 | } |
| 72 | |
avm99963 | 28fddc6 | 2021-02-05 20:33:48 +0100 | [diff] [blame] | 73 | function injectDarkModeButton(rightControl) { |
| 74 | var darkThemeSwitch = document.createElement('material-button'); |
| 75 | darkThemeSwitch.classList.add('TWPT-dark-theme', 'TWPT-btn--with-badge'); |
| 76 | darkThemeSwitch.setAttribute('button', ''); |
| 77 | darkThemeSwitch.setAttribute( |
| 78 | 'title', chrome.i18n.getMessage('inject_ccdarktheme_helper')); |
| 79 | |
| 80 | darkThemeSwitch.addEventListener('click', e => { |
| 81 | chrome.storage.sync.get(null, currentOptions => { |
| 82 | currentOptions.ccdarktheme_switch_status = |
| 83 | !options.ccdarktheme_switch_status; |
| 84 | chrome.storage.sync.set(currentOptions, _ => { |
| 85 | location.reload(); |
| 86 | }); |
| 87 | }); |
| 88 | }); |
| 89 | |
| 90 | var switchContent = document.createElement('div'); |
| 91 | switchContent.classList.add('content'); |
| 92 | |
| 93 | var icon = document.createElement('material-icon'); |
| 94 | |
| 95 | var i = document.createElement('i'); |
| 96 | i.classList.add('material-icon-i', 'material-icons-extended'); |
| 97 | i.textContent = 'brightness_4'; |
| 98 | |
| 99 | icon.appendChild(i); |
| 100 | switchContent.appendChild(icon); |
| 101 | darkThemeSwitch.appendChild(switchContent); |
| 102 | |
| 103 | var badgeContent = createExtBadge(); |
| 104 | |
| 105 | darkThemeSwitch.appendChild(badgeContent); |
| 106 | |
| 107 | rightControl.style.width = |
| 108 | (parseInt(window.getComputedStyle(rightControl).width) + 58) + 'px'; |
| 109 | rightControl.insertAdjacentElement('afterbegin', darkThemeSwitch); |
| 110 | } |
| 111 | |
avm99963 | f592396 | 2020-12-07 16:44:37 +0100 | [diff] [blame] | 112 | function addBatchLockBtn(readToggle) { |
| 113 | var clone = readToggle.cloneNode(true); |
| 114 | clone.setAttribute('debugid', 'batchlock'); |
| 115 | clone.classList.add('TWPT-btn--with-badge'); |
| 116 | clone.setAttribute('title', chrome.i18n.getMessage('inject_lockbtn')); |
| 117 | clone.querySelector('material-icon').setAttribute('icon', 'lock'); |
| 118 | clone.querySelector('i.material-icon-i').textContent = 'lock'; |
| 119 | |
| 120 | var badge = createExtBadge(); |
| 121 | clone.append(badge); |
| 122 | |
| 123 | clone.addEventListener('click', function() { |
| 124 | var modal = document.querySelector('.pane[pane-id="default-1"]'); |
| 125 | |
| 126 | var dialog = document.createElement('material-dialog'); |
| 127 | dialog.setAttribute('role', 'dialog'); |
| 128 | dialog.setAttribute('aria-modal', 'true'); |
| 129 | dialog.classList.add('TWPT-dialog'); |
| 130 | |
| 131 | var header = document.createElement('header'); |
| 132 | header.setAttribute('role', 'presentation'); |
| 133 | header.classList.add('TWPT-dialog-header'); |
| 134 | |
| 135 | var title = document.createElement('div'); |
| 136 | title.classList.add('TWPT-dialog-header--title', 'title'); |
| 137 | title.textContent = chrome.i18n.getMessage('inject_lockbtn'); |
| 138 | |
| 139 | header.append(title); |
| 140 | |
| 141 | var main = document.createElement('main'); |
| 142 | main.setAttribute('role', 'presentation'); |
| 143 | main.classList.add('TWPT-dialog-main'); |
| 144 | |
| 145 | var p = document.createElement('p'); |
| 146 | p.textContent = chrome.i18n.getMessage('inject_lockdialog_desc'); |
| 147 | |
| 148 | main.append(p); |
| 149 | |
| 150 | dialog.append(header, main); |
| 151 | |
| 152 | var footers = [['lock', 'unlock', 'cancel'], ['reload', 'close']]; |
| 153 | |
| 154 | for (var i = 0; i < footers.length; ++i) { |
| 155 | var footer = document.createElement('footer'); |
| 156 | footer.setAttribute('role', 'presentation'); |
| 157 | footer.classList.add('TWPT-dialog-footer'); |
| 158 | footer.setAttribute('data-footer-id', i); |
| 159 | |
| 160 | if (i > 0) footer.classList.add('is-hidden'); |
| 161 | |
| 162 | footers[i].forEach(action => { |
| 163 | var btn = document.createElement('material-button'); |
| 164 | btn.setAttribute('role', 'button'); |
| 165 | btn.classList.add('TWPT-dialog-footer-btn'); |
| 166 | if (i == 1) btn.classList.add('is-disabled'); |
| 167 | |
| 168 | switch (action) { |
| 169 | case 'lock': |
| 170 | case 'unlock': |
| 171 | btn.addEventListener('click', _ => { |
| 172 | if (btn.classList.contains('is-disabled')) return; |
| 173 | var message = { |
| 174 | action, |
| 175 | prefix: 'TWPT-batchlock', |
| 176 | }; |
| 177 | window.postMessage(message, '*'); |
| 178 | }); |
| 179 | break; |
| 180 | |
| 181 | case 'cancel': |
| 182 | case 'close': |
| 183 | btn.addEventListener('click', _ => { |
| 184 | if (btn.classList.contains('is-disabled')) return; |
| 185 | modal.classList.remove('visible'); |
| 186 | modal.style.display = 'none'; |
| 187 | removeChildNodes(modal); |
| 188 | }); |
| 189 | break; |
| 190 | |
| 191 | case 'reload': |
| 192 | btn.addEventListener('click', _ => { |
| 193 | if (btn.classList.contains('is-disabled')) return; |
| 194 | window.location.reload() |
| 195 | }); |
| 196 | break; |
| 197 | } |
| 198 | |
| 199 | var content = document.createElement('div'); |
| 200 | content.classList.add('content', 'TWPT-dialog-footer-btn--content'); |
| 201 | content.textContent = |
| 202 | chrome.i18n.getMessage('inject_lockdialog_btn_' + action); |
| 203 | |
| 204 | btn.append(content); |
| 205 | footer.append(btn); |
| 206 | }); |
| 207 | |
| 208 | var clear = document.createElement('div'); |
| 209 | clear.style.clear = 'both'; |
| 210 | |
| 211 | footer.append(clear); |
| 212 | dialog.append(footer); |
| 213 | } |
| 214 | |
| 215 | removeChildNodes(modal); |
| 216 | modal.append(dialog); |
| 217 | modal.classList.add('visible', 'modal'); |
| 218 | modal.style.display = 'flex'; |
| 219 | }); |
| 220 | readToggle.parentNode.insertBefore( |
| 221 | clone, (readToggle.nextSibling ||Â readToggle)); |
| 222 | } |
| 223 | |
avm99963 | 90cc2e3 | 2021-02-05 18:14:16 +0100 | [diff] [blame] | 224 | function injectPreviousPostsLinks(nameElement) { |
| 225 | var mainCardContent = getNParent(nameElement, 3); |
| 226 | if (mainCardContent === null) { |
| 227 | console.error( |
| 228 | '[previousposts] Couldn\'t find |.main-card-content| element.'); |
| 229 | return; |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 230 | } |
avm99963 | 90cc2e3 | 2021-02-05 18:14:16 +0100 | [diff] [blame] | 231 | |
| 232 | var forumId = location.href.split('/forum/')[1].split('/')[0] || '0'; |
| 233 | |
| 234 | var name = escapeUsername(nameElement.textContent); |
| 235 | var query1 = encodeURIComponent( |
| 236 | '(creator:"' + name + '" | replier:"' + name + '") forum:' + forumId); |
| 237 | var query2 = encodeURIComponent( |
| 238 | '(creator:"' + name + '" | replier:"' + name + '") forum:any'); |
| 239 | |
| 240 | var container = document.createElement('div'); |
| 241 | container.classList.add('TWPT-previous-posts'); |
| 242 | |
| 243 | var badge = createExtBadge(); |
| 244 | container.appendChild(badge); |
| 245 | |
| 246 | var linkContainer = document.createElement('div'); |
| 247 | linkContainer.classList.add('TWPT-previous-posts--links'); |
| 248 | |
| 249 | addProfileHistoryLink(linkContainer, 'forum', query1); |
| 250 | addProfileHistoryLink(linkContainer, 'all', query2); |
| 251 | |
| 252 | container.appendChild(linkContainer); |
| 253 | |
| 254 | mainCardContent.appendChild(container); |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | const watchedNodesSelectors = [ |
avm99963 | 28fddc6 | 2021-02-05 20:33:48 +0100 | [diff] [blame] | 258 | // App container (used to set up the intersection observer and inject the dark |
| 259 | // mode button) |
avm99963 | 1170703 | 2021-02-05 19:11:25 +0100 | [diff] [blame] | 260 | 'ec-app', |
| 261 | |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 262 | // Load more bar (for the "load more"/"load all" buttons) |
| 263 | '.load-more-bar', |
| 264 | |
avm99963 | 90cc2e3 | 2021-02-05 18:14:16 +0100 | [diff] [blame] | 265 | // Username span inside ec-user (user profile view) |
| 266 | 'ec-user .main-card .header > .name > span', |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 267 | |
| 268 | // Rich text editor |
| 269 | 'ec-movable-dialog', |
| 270 | 'ec-rich-text-editor', |
| 271 | |
| 272 | // Read/unread bulk action in the list of thread, for the batch lock feature |
| 273 | 'ec-bulk-actions material-button[debugid="mark-read-button"]', |
| 274 | 'ec-bulk-actions material-button[debugid="mark-unread-button"]', |
| 275 | ]; |
| 276 | |
| 277 | function handleCandidateNode(node) { |
| 278 | if (typeof node.classList !== 'undefined') { |
avm99963 | 28fddc6 | 2021-02-05 20:33:48 +0100 | [diff] [blame] | 279 | if (('tagName' in node) && node.tagName == 'EC-APP') { |
| 280 | // Set up the intersectionObserver |
| 281 | if (typeof intersectionObserver === 'undefined') { |
| 282 | var scrollableContent = node.querySelector('.scrollable-content'); |
| 283 | if (scrollableContent !== null) { |
| 284 | intersectionOptions = { |
| 285 | root: scrollableContent, |
| 286 | rootMargin: '0px', |
| 287 | threshold: 1.0, |
| 288 | }; |
avm99963 | 1170703 | 2021-02-05 19:11:25 +0100 | [diff] [blame] | 289 | |
avm99963 | 28fddc6 | 2021-02-05 20:33:48 +0100 | [diff] [blame] | 290 | intersectionObserver = new IntersectionObserver( |
| 291 | intersectionCallback, intersectionOptions); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | // Inject the dark mode button |
| 296 | if (options.ccdarktheme && options.ccdarktheme_mode == 'switch') { |
| 297 | var rightControl = node.querySelector('header .right-control'); |
| 298 | if (rightControl !== null) injectDarkModeButton(rightControl); |
avm99963 | d24e2db | 2021-02-05 20:03:55 +0100 | [diff] [blame] | 299 | } |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 300 | } |
| 301 | |
avm99963 | 1170703 | 2021-02-05 19:11:25 +0100 | [diff] [blame] | 302 | // Start the intersectionObserver for the "load more"/"load all" buttons |
| 303 | // inside a thread |
| 304 | if ((options.thread || options.threadall) && |
| 305 | node.classList.contains('load-more-bar')) { |
| 306 | if (typeof intersectionObserver !== 'undefined') { |
| 307 | if (options.thread) |
| 308 | intersectionObserver.observe(node.querySelector('.load-more-button')); |
| 309 | if (options.threadall) |
| 310 | intersectionObserver.observe(node.querySelector('.load-all-button')); |
| 311 | } else { |
| 312 | console.warn( |
| 313 | '[infinitescroll] ' + |
| 314 | 'The intersectionObserver is not ready yet.'); |
| 315 | } |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | // Show the "previous posts" links |
| 319 | // Here we're selecting the 'ec-user > div' element (unique child) |
avm99963 | 90cc2e3 | 2021-02-05 18:14:16 +0100 | [diff] [blame] | 320 | if (options.history && |
| 321 | node.matches('ec-user .main-card .header > .name > span')) { |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 322 | injectPreviousPostsLinks(node); |
| 323 | } |
| 324 | |
| 325 | // Fix the drag&drop issue with the rich text editor |
| 326 | // |
| 327 | // We target both tags because in different contexts different |
| 328 | // elements containing the text editor get added to the DOM structure. |
| 329 | // Sometimes it's a EC-MOVABLE-DIALOG which already contains the |
| 330 | // EC-RICH-TEXT-EDITOR, and sometimes it's the EC-RICH-TEXT-EDITOR |
| 331 | // directly. |
| 332 | if (options.ccdragndropfix && ('tagName' in node) && |
| 333 | (node.tagName == 'EC-MOVABLE-DIALOG' || |
| 334 | node.tagName == 'EC-RICH-TEXT-EDITOR')) { |
| 335 | applyDragAndDropFix(node); |
| 336 | } |
| 337 | |
| 338 | // Inject the batch lock button in the thread list |
| 339 | if (options.batchlock && nodeIsReadToggleBtn(node)) { |
| 340 | addBatchLockBtn(node); |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 345 | function mutationCallback(mutationList, observer) { |
| 346 | mutationList.forEach((mutation) => { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 347 | if (mutation.type == 'childList') { |
| 348 | mutation.addedNodes.forEach(function(node) { |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 349 | handleCandidateNode(node); |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 350 | }); |
| 351 | } |
| 352 | }); |
| 353 | } |
| 354 | |
avm99963 | adf9086 | 2020-04-12 13:27:45 +0200 | [diff] [blame] | 355 | function intersectionCallback(entries, observer) { |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 356 | entries.forEach(entry => { |
| 357 | if (entry.isIntersecting) { |
| 358 | entry.target.click(); |
| 359 | } |
| 360 | }); |
| 361 | }; |
| 362 | |
| 363 | var observerOptions = { |
| 364 | childList: true, |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 365 | subtree: true, |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 366 | }; |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 367 | |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 368 | chrome.storage.sync.get(null, function(items) { |
| 369 | options = items; |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 370 | |
avm99963 | a2945b6 | 2020-11-27 00:32:02 +0100 | [diff] [blame] | 371 | var startup = |
| 372 | JSON.parse(document.querySelector('html').getAttribute('data-startup')); |
| 373 | authuser = startup[2][1] || '0'; |
| 374 | |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 375 | // Before starting the mutation Observer, check whether we missed any |
avm99963 | 1170703 | 2021-02-05 19:11:25 +0100 | [diff] [blame] | 376 | // mutations by manually checking whether some watched nodes already |
| 377 | // exist. |
avm99963 | 490114d | 2021-02-05 16:12:20 +0100 | [diff] [blame] | 378 | var cssSelectors = watchedNodesSelectors.join(','); |
| 379 | document.querySelectorAll(cssSelectors) |
| 380 | .forEach(node => handleCandidateNode(node)); |
| 381 | |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 382 | mutationObserver = new MutationObserver(mutationCallback); |
avm99963 | e4cac40 | 2020-12-03 16:10:58 +0100 | [diff] [blame] | 383 | mutationObserver.observe(document.body, observerOptions); |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 384 | |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 385 | if (options.fixedtoolbar) { |
| 386 | injectStyles( |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 387 | 'ec-bulk-actions{position: sticky; top: 0; background: var(--TWPT-primary-background, #fff); z-index: 96;}'); |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 388 | } |
avm99963 | ae6a26d | 2020-04-12 14:03:51 +0200 | [diff] [blame] | 389 | |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 390 | if (options.increasecontrast) { |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 391 | injectStyles( |
avm99963 | a2a0644 | 2020-11-25 21:11:10 +0100 | [diff] [blame] | 392 | '.thread-summary.read:not(.checked){background: var(--TWPT-thread-read-background, #ecedee)!important;}'); |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 393 | } |
avm99963 | 0f9503f | 2020-07-27 13:56:52 +0200 | [diff] [blame] | 394 | |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 395 | if (options.stickysidebarheaders) { |
| 396 | injectStyles( |
avm99963 | 0bc113a | 2020-09-07 13:02:11 +0200 | [diff] [blame] | 397 | 'material-drawer .main-header{background: var(--TWPT-drawer-background, #fff)!important; position: sticky; top: 0; z-index: 1;}'); |
| 398 | } |
| 399 | |
avm99963 | 698d376 | 2021-02-16 01:19:54 +0100 | [diff] [blame] | 400 | if (options.enhancedannouncementsdot) { |
| 401 | injectStylesheet( |
| 402 | chrome.runtime.getURL('injections/enhanced_announcements_dot.css')); |
| 403 | } |
| 404 | |
avm99963 | d98126f | 2021-02-17 10:44:36 +0100 | [diff] [blame] | 405 | if (options.repositionexpandthread) { |
| 406 | injectStylesheet( |
| 407 | chrome.runtime.getURL('injections/reposition_expand_thread.css')); |
| 408 | } |
| 409 | |
avm99963 | 129942f | 2020-09-08 02:07:18 +0200 | [diff] [blame] | 410 | if (options.ccforcehidedrawer) { |
| 411 | var drawer = document.querySelector('material-drawer'); |
| 412 | if (drawer !== null && drawer.classList.contains('mat-drawer-expanded')) { |
| 413 | document.querySelector('.material-drawer-button').click(); |
| 414 | } |
| 415 | } |
avm99963 | f592396 | 2020-12-07 16:44:37 +0100 | [diff] [blame] | 416 | |
| 417 | if (options.batchlock) { |
| 418 | injectScript(chrome.runtime.getURL('injections/batchlock_inject.js')); |
| 419 | } |
avm99963 | 129fb50 | 2020-08-28 05:18:53 +0200 | [diff] [blame] | 420 | }); |