I'm trying to parse a web page (any web page actually) and dynamically apply some adjustments to font sizes of DOM elements.
As far as I could see:
element.style.fontSizewill return the value plus unit, e.g.:"11px", or"1em", or"1rem", which is fine for me, BUT...element.style.fontSizewill return no value if the font size is defined via a css class. So if I want to address all DOM elements (most of which won't have their font-size defined in theirstyleattribute), I'll have to use getComputedStyle instead, BUT...getComputedStyleseems to return all font sizes in px, even if it was originally defined in em or rem in the css, e.g.: font size defined as"1rem"=>getComputedStylereturns"16px"instead.
For my purpose, I'd like to know the original font-size value with its original unit, so get "1rem" rather than "16px".
Is it possible?