I am building an extension that allows an admin to track and manage Chrome extensions installed on their team members' browsers. Being able to see the icons of the extensions would make it easier to recognize the Chrome extensions more quickly. It does not necessarily block me, but it just makes the user experience significantly worse. - Hao
Thanks for that context. Based on this it sounds like there's not much opportunity for your extension to show a window, popup, or other extension UI that you could use to send images back to your server. If you had something like a popup that users would occasionally invoke, you could use that temporary chrome-extension://<ID> page context to asynchronously retrieve extension icons and push them to your server shortly after page load.
We haven't quite settled how to handle chrome://extension-icon/* URLs in Manifest V3. This could be rolled into the updates we're working on for favicons (i.e. chrome://favicon URls) or handled separately. Until we have the design ironed out, implemented, and shipped you won't be able to get extension icon data in the etension's service worker.
In the meantime, one idea that leaps to mind is to use either the Tabs or Windows API to create a short lived temporary context. Neither approach will require any new permissions.
One approach I've seen existing Manifest V2 extension use for similar purposes is use the
Tabs API to create a new background tab and have the page's script immediately close the tab once your work is done. If the user has multiple windows open, this could be further refined to open the tab in a window that the user doesn't currently have focused in order to minimize potential user distraction.
function spawnSyncIconsPage() {
chrome.tabs.create({
url: chrome.runtime.getURL('sync-icons.html'),
active: false,
});
}
Alternatively, you could use the
Windows API to spawn a new minimized window and have the page's script close the window once your work is complete.
function spawnSyncIconsPage() {
return chrome.windows.create({
url: chrome.runtime.getURL('sync-icons.html'),
state: chrome.windows.WindowState.MINIMIZED,
});
}
Both approaches have the potential to cause a flash on the user's screen, either in the tab bar or in the toolbar/dock/application launcher. There are some other strategies you may want to consider in order to minimize the chances the user will see this. For example, you could treat this sync work as a periodic job that runs at most once every N days, use the
Idle API (and permission) to detect when the device is locked or idle, or only perform a sync when an extension is newly
installed (Management API and permission).
chrome.management.onInstalled.addListener((info) => {