Skip to content

How does stylus insert css after the original css but before the page is rendered? #1179

Answered by tophf
giggity-hub asked this question in Q&A
Discussion options

You must be logged in to vote

Hmm indeed Chrome doesn't put the css declared in manifest.json at the end of style list. Oh well, yet another bug/deficiency that won't be fixed in this century if ever.

In that case you'll have to add a DOM element in a js content script that runs at document_start and then move it after the body element:

"content_scripts": [{
  "matches": ["https://www.example.com/*"],
  "js": ["content.js"],
  "run_at": "document_start"
}]
const style = document.createElement('style');
style.textContent = `
body { color: red }
`;
document.documentElement.appendChild(style);

new MutationObserver((mutations, observer) => {
  if (document.body) {
    observer.disconnect();
    document.documentElement.a…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@giggity-hub
Comment options

@tophf
Comment options

@giggity-hub
Comment options

Comment options

You must be logged in to vote
3 replies
@giggity-hub
Comment options

@cheater
Comment options

@tophf
Comment options

Answer selected by tophf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants