You CAN affect the document’s stylesheets in JS… a couple of ways, actually.
To manipulate global CSS (non-element CSS) using JavaScript, you can create a <style>
tag like any other HTML element. From there you’ve got a couple options for applying the styling.
-
Set innerHTML
-
Or use a method of the CSSStyleSheet class.
Source
CSSStyleSheet - Web APIs | MDN
Set CSS styles with javascript