Fix extension stylesheet order (?) by fregante · Pull Request #9516 · refined-github/refined-github · GitHub
Skip to content

Fix extension stylesheet order (?)#9516

Draft
fregante wants to merge 1 commit into
mainfrom
css-loading
Draft

Fix extension stylesheet order (?)#9516
fregante wants to merge 1 commit into
mainfrom
css-loading

Conversation

@fregante

Copy link
Copy Markdown
Member

After re-reading #9335 (comment), I realized that document_start is obviously the wrong time to add a stylesheet meant to override the page's.

Now I don't know if this PR makes any difference nor if it works correctly on GHE.

  • Verify injection order in all browsers
    • main
    • this PR
  • ensure it works without issues on GHE

@SunsetTechuila

SunsetTechuila commented May 18, 2026

Copy link
Copy Markdown
Contributor

@SunsetTechuila

SunsetTechuila commented May 18, 2026

Copy link
Copy Markdown
Contributor

Chrome docs have conflicting info:

  • extensionTypes/RunAt: "The soonest that the JavaScript or CSS will be injected into the tab."
  • content-scripts/run_time: "The run_at field controls when JavaScript files are injected into the web page."
  • content-scripts/css: "These are injected in the order they appear in this array, before any DOM is constructed or displayed for the page"

@fregante

fregante commented May 18, 2026

Copy link
Copy Markdown
Member Author

According to MDN, Chrome ignores run_at for CSS

I don’t think it's quite accurate: CSS must always precede the JS and it should precede the first paint, as implied by the table:

document_start string Scripts are injected after any files from css, but before any other DOM is constructed or any other script is run.

My expectations are:

  • The CSS is injected at the end of head, unless run_at === document_start, in which case it's injected at the beginning of head

This would explain what you said before:

CSS specified in the manifest overrides page inline styles in Firefox but not in Chrome

@fregante

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

2 participants