Open lukasfarina opened 9 months ago
<img src="${chrome.runtime.getURL(src)}" />
https://crxjs.dev/vite-plugin/getting-started/vanilla-js/add-content-script#get-the-right-url
<img src="${chrome.runtime.getURL(src)}" />
https://crxjs.dev/vite-plugin/getting-started/vanilla-js/add-content-script#get-the-right-url
I was trying the same thing in january this year in popup.js it works fine, but not in content_script. I've ended up hosting the images on my website and loading by https uri
I believe this one should be closed as getURL is the solution @jacksteamdev
chrome.runtime.getURL
is undefined when running on JavaScript context MAIN
instead of ISOLATED
, maybe a workaround should be provided by this plugin (e.g. scoped variable) but perhaps that's outside the scope of this project, see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/ExecutionWorld
chrome.runtime.getURL
is undefined when running on JavaScript contextMAIN
instead ofISOLATED
, maybe a workaround should be provided by this plugin (e.g. scoped variable) but perhaps that's outside the scope of this project, see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/ExecutionWorld
if youre running in main world then you need the extension id - that need request_web_permissions
in manifest i guess.
Topic of using the extension id in mainworld is a work in progress. Perhaps you could pass the extension id or the url of image from the isolated world?
Some work done #851 and #695
Build tool
Vite
Where do you see the problem?
Describe the bug
When trying to import an image asset in a content script, the path entered is relative to the website and not the extension folder.
Reproduction
import Logo from '../path/logo.png'
Logs
System Info
Severity
annoyance