ps module (v0.1.x)
applyStyle(elements, values) applies CSS style properties on all target elements in a list.
ps.applyStyle(Array.from(document.querySelectorAll(".target")), {
color: "#fff",
background: "#111",
});
It safely ignores elements that do not expose a style property.
injectCSS(styleText)
Injects CSS into document.head and avoids duplicate inserts for the same content.
const inserted = ps.injectCSS(`
.target {
border: 0.1em solid #59C2FF;
border-radius: 0.5em;
}
`);
if (!inserted) {
console.log("Style already exists or could not be injected.");
}
injectCSS returns:
truewhen CSS is insertedfalsewhen the input is empty,headis unavailable, or matching CSS already exists