web-highlighter
Version:
✨A no-runtime dependency lib for text highlighting & persistence on any website ✨🖍️
22 lines (16 loc) • 537 B
text/typescript
/**
* inject styles
*/
import { STYLESHEET_ID, getStylesheet } from '@src/util/const';
export const initDefaultStylesheet = () => {
const styleId = STYLESHEET_ID;
let $style: HTMLStyleElement = document.getElementById(styleId) as HTMLStyleElement;
if (!$style) {
const $cssNode = document.createTextNode(getStylesheet());
$style = document.createElement('style');
$style.id = styleId;
$style.appendChild($cssNode);
document.head.appendChild($style);
}
return $style;
};