How to get icon image data of other extension?

Hello everyone!

Recently, I’ve been working on developing an extension manager (using Manifest V3) for personal use, and I’ve encountered an issue regarding the loading icons of other extensions.

I am using the browser.management.getAll() API, which provides me with an array of ExtensionInfo objects. Within these objects, the icons field contains the icon URL I need, something like moz-extension://<extension-id>/path/to/icon.png . However, I can’t get the actual image data from thoose URL.

I’ve tried both the fetch API and canvas+img method. Unfortunately, I’ve hit a roadblock due to stringent CORS policies. Even after including <all_urls> in the host_permissions and granting the necessary permissions, this restriction still exist.


Does anyone is aware of a solution or approach? Your insights would be greatly appreciated!

1 Like

Well, if I’m wrong, I apologize, but it seems to me like this is entirely an AI-generated response?

I say this because of:

Dealing with CORS policies in Chrome extensions can be tricky

It’s clear that I was asking about how to handle this issue in Firefox, not Chrome.

  1. Use chrome.runtime.getURL in the Context of Each Extension

Make no sense.

  1. Request the Icons through Content Scripts。

Same as above.

  1. Proxy the Requests through Your Own Extension

This is exactly the method I’m trying, but the additional content doesn’t offer any solutions.

  1. Use Permissions

Still referring to methods I’ve already tried.

  1. Alternative Approaches

Completely unclear what this section is saying.


Thank you for your response, but unfortunately, it’s not very helpful.

1 Like

It is, just like his other post.
I’ve flagged both as spam.

2 Likes

You can use the AMO API ( https://mozilla.github.io/addons-server/topics/api/index.html ) to get extension icons.

For example, open the URL https://addons.mozilla.org/api/v5/addons/addon/uBlock0@raymondhill.net/ and view the icons and icon_url properties.

2 Likes

This seems like a viable solution, I will try it. Thank you!

Hm… for the most part it makes sense that CORS policies prevent one extension from accessing assets in another extension, but in the specific case of trying to retrieve the icon URL exposed by browser.management.getAll() it seems out of place.

@7sDream, if it’s not too much trouble, would you mind opening a bug on bugzil.la and attaching a minimal reproduction that demonstrates the error?

2 Likes

OK, I’d love to. I can make a minimal example tomorrow night and will update the bugzilla URL here after I post it.

1 Like

@dotproto

Here is the bug report on bugzilla : https://bugzilla.mozilla.org/show_bug.cgi?id=1905397

For convenience, I upload the example code here too: get-addon-icon.zip (557.1 KB)

2 Likes