-
Is it possible to get either the path to the CSS file of content script or the file contents? Not sure how to achieve this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Apparently, this won't work: Injecting in shadow-root:
In both cases, I get an error: Not sure why, because path is correct... |
Beta Was this translation helpful? Give feedback.
-
Delightful... Seems like these are the necessary steps to support MV2 & MV3. I stripped away all of the other configuration that I have, that isn't relevant to the question. export default defineConfig({
manifest: ({ manifestVersion }) => {
const hosts = ['https://*/*', 'http://*/*']
const config: UserManifest = {
web_accessible_resources: [
{
resources: ['/content-scripts/inject.css'],
matches: hosts,
},
],
}
if (manifestVersion === 2) {
config.web_accessible_resources = ['/content-scripts/inject.css']
}
return config
},
}) And then in export default defineContentScript({
allFrames: true,
matches: ['https://*/*', 'http://*/*'],
async main() {
// ...
let inlineCSS = await fetch(
browser.runtime.getURL('/content-scripts/inject.css'),
).then((r) => r.text())
}
}) Thanks again @aklinker1 , you rock! 🤘 |
Beta Was this translation helpful? Give feedback.
Delightful... Seems like these are the necessary steps to support MV2 & MV3. I stripped away all of the other configuration that I have, that isn't relevant to the question.
And then in
inject.content.ts
(or whatever the filename is)