MCPcopy
hub / github.com/ChinaGodMan/UserScripts / injectCSS

Function injectCSS

youtube-dynamic-grid/youtube-dynamic-grid.user.js:483–499  ·  view source on GitHub ↗

* Injects or updates the CSS style element for the grid.

()

Source from the content-addressed store, hash-verified

481 * Injects or updates the CSS style element for the grid.
482 */
483 injectCSS() {
484 if (isPlaylistPage()) {
485 logger('Skipping CSS injection on playlist page')
486 this.removeCSS()
487 return
488 }
489 let style = document.getElementById('dynamic-grid-style')
490 if (!style) {
491 style = document.createElement('style')
492 style.id = 'dynamic-grid-style'
493 const nonce = document.querySelector('meta[name="csp-nonce"]')?.content
494 if (nonce) style.nonce = nonce
495 document.head.appendChild(style)
496 logger('Injected CSS style element', 'debug')
497 }
498 this.updateCSS(this.calculateItemsPerRow())
499 },
500
501 /**
502 * Updates the CSS rule for the specified number of items per row.

Callers

nothing calls this directly

Calls 2

isPlaylistPageFunction · 0.85
loggerFunction · 0.85

Tested by

no test coverage detected