@@ -5,38 +5,38 @@ import { hit, logMessage, hijackAttachShadow } from '../helpers';
55 * @scriptlet inject-css-in-shadow-dom
66 *
77 * @description
8- * Injects CSS rule into selected Shadow DOM subtrees on a page
8+ * Injects CSS rule into selected Shadow DOM subtrees on a page.
99 *
1010 * ### Syntax
1111 *
1212 * ```text
13- * example.org#%#//scriptlet('inject-css-in-shadow-dom', cssRule[, hostSelector])
13+ * example.org#%#//scriptlet('inject-css-in-shadow-dom', cssRule[, hostSelector[, cssInjectionMethod] ])
1414 * ```
1515 *
16- * - `cssRule` — required, string representing a single css rule
16+ * - `cssRule` — required, string representing a single CSS rule.
1717 * - `hostSelector` — optional, string, selector to match shadow host elements.
1818 * CSS rule will be only applied to shadow roots inside these elements.
19- * Defaults to injecting css rule into all available roots.
20- * - `cssInjectionMethod` — optional, string, method to inject css rule into shadow dom .
19+ * Defaults to injecting CSS rule into all available roots.
20+ * - `cssInjectionMethod` — optional, string, method to inject CSS rule into shadow DOM .
2121 * Available methods are:
2222 * - `adoptedStyleSheets` — injects the CSS rule using adopted style sheets (default option).
2323 * - `styleTag` — injects the CSS rule using a `style` tag.
2424 *
2525 * ### Examples
2626 *
27- * 1. Apply style to all shadow dom subtrees
27+ * 1. Apply style to all shadow DOM subtrees:
2828 *
2929 * ```adblock
3030 * example.org#%#//scriptlet('inject-css-in-shadow-dom', '#advertisement { display: none !important; }')
3131 * ```
3232 *
33- * 1. Apply style to a specific shadow dom subtree
33+ * 1. Apply style to a specific shadow DOM subtree:
3434 *
3535 * ```adblock
3636 * example.org#%#//scriptlet('inject-css-in-shadow-dom', '#content { margin-top: 0 !important; }', '#banner')
3737 * ```
3838 *
39- * 1. Apply style to all shadow dom subtrees using style tag
39+ * 1. Apply style to all shadow DOM subtrees using style tag:
4040 *
4141 * ```adblock
4242 * example.org#%#//scriptlet('inject-css-in-shadow-dom', '.ads { display: none !important; }', '', 'styleTag')
@@ -52,7 +52,7 @@ export function injectCssInShadowDom(
5252 hostSelector = '' ,
5353 cssInjectionMethod = 'adoptedStyleSheets' ,
5454) {
55- // do nothing if browser does not support ShadowRoot, Proxy or Reflect
55+ // Do nothing if browser does not support ShadowRoot, Proxy or Reflect:
5656 // https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot
5757 if ( ! Element . prototype . attachShadow || typeof Proxy === 'undefined' || typeof Reflect === 'undefined' ) {
5858 return ;
@@ -63,7 +63,7 @@ export function injectCssInShadowDom(
6363 return ;
6464 }
6565
66- // Prevent url() and image-set() styles from being applied
66+ // Prevent url() and image-set() styles from being applied:
6767 if ( cssRule . match ( / ( u r l | i m a g e - s e t ) \( .* \) / i) ) {
6868 logMessage ( source , '"url()" function is not allowed for css rules' ) ;
6969 return ;
@@ -81,7 +81,7 @@ export function injectCssInShadowDom(
8181 } ;
8282
8383 /**
84- * Injects CSS rules into a shadow root using the adoptedStyleSheets API
84+ * Injects CSS rules into a shadow root using the adoptedStyleSheets API.
8585 *
8686 * @param {ShadowRoot } shadowRoot - The shadow root to inject styles into
8787 * @private
@@ -93,7 +93,7 @@ export function injectCssInShadowDom(
9393 */
9494 const injectAdoptedStyleSheets = ( shadowRoot ) => {
9595 try {
96- // adoptedStyleSheets and CSSStyleSheet constructor are not supported by old browsers
96+ // adoptedStyleSheets and CSSStyleSheet constructor are not supported by old browsers:
9797 // https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets
9898 // https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/CSSStyleSheet
9999 const stylesheet = new CSSStyleSheet ( ) ;
0 commit comments