-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: injection to MAIN environment #59
Comments
As a temporary solution I have to parse the manifest to find the right file name
|
Couple of questions. To confirm, that temporary solution works without any issues? How are you defining the content script in your manifest? Is your original inject.js script importing other modules at all? |
The answer to both questions is yes. Everything is working so far, but I haven't written anything complicated yet. I moved inject.js to web_accessible_resources (from content_scripts) and ran registerContentScripts from background.js.
inject.js for now it's very simple
|
@Bighamster if you use world: isolated, not main, would your original code work? i try to use registerContentScripts to register content scripts from background script (so no declaration in manifest.json), but the backgroud script keeps saying: Error: Could not load javascript 'content.js' for content script. i'm also not sure the js path in registerContentScripts is relative to which one, the background folder in dev src, the dev root src, or actually in /dist even during development. from the code generated by npm run dev, seems they are reference to dev src folders. (not sure what is the @Vite folder, can't find it in node module folder) |
For the extension that I'm building, I'm trying to inject to the MAIN environment
but generated code
(async()=>{await import(chrome.runtime.getURL("assets/src/entries/content-scripts/inject.8e490e7d.js"))})();
raise an error chrome.runtime.getURL is not a function in console
I understand that neither the file (inject.8e490e7d.js) nor the method (chrome.runtime.getURL) exists in MAIN context, but how to inject correctly?
The text was updated successfully, but these errors were encountered: