How to Get Extension Manifest Information

By  on  

Working on a web extension can be kinda wild -- on one side you're essentially just coding a website, on the other side you're limited to what the browser says you can do in the extension execution environment. One change in that environment is coming January 2023 -- pushing extensions to move to manifest version 3. I recently got curious about whether other popular extensions had completed the version 3 update.

Executing the following command in the background page (manifest version 2) or service worker (version 3) will provide you the extension's manifest:

chrome.runtime.getManifest()

The getManifest call returns a large object detailing the extension's manifest. Here's what you'd see for the MetaMask browser extension:

{
    "author": "https://metamask.io",
    "background": {
        "page": "background.html",
        "persistent": true
    },
    "browser_action": {
        "default_icon": {
            "16": "images/icon-16.png",
            "19": "images/icon-19.png",
            "32": "images/icon-32.png",
            "38": "images/icon-38.png",
            "64": "images/icon-64.png",
        },
        "default_popup": "popup.html",
        "default_title": "MetaMask"
    },
    "commands": {
        "_execute_browser_action": {
            "suggested_key": {
                "chromeos": "Alt+Shift+M",
                "linux": "Alt+Shift+M",
                "mac": "Alt+Shift+M",
                "windows": "Alt+Shift+M"
            }
        }
    },
    "content_scripts": [
        {
            "all_frames": true,
            "js": [
                "disable-console.js",
                "globalthis.js",
                "lockdown-install.js",
                "lockdown-run.js",
                "lockdown-more.js",
                "contentscript.js"
            ],
            "matches": [
                "file://*/*",
                "http://*/*",
                "https://*/*"
            ],
            "run_at": "document_start"
        }
    ],
    "current_locale": "en_US",
    "default_locale": "en",
    "description": "An Ethereum Wallet in your Browser",
    "externally_connectable": {
        "ids": [
            "*"
        ],
        "matches": [
            "https://metamask.io/*"
        ]
    },
    "icons": {
        "16": "images/icon-16.png",
        "19": "images/icon-19.png",
        "32": "images/icon-32.png",
        "38": "images/icon-38.png",
        "48": "images/icon-48.png",
        "64": "images/icon-64.png",
    },
    "manifest_version": 2,
    "minimum_chrome_version": "66",
    "name": "MetaMask",
    "permissions": [
        "storage",
        "unlimitedStorage",
        "clipboardWrite",
        "http://localhost:8545/",
        "https://*.infura.io/",
        "https://lattice.gridplus.io/*",
        "activeTab",
        "webRequest",
        "*://*.eth/",
        "notifications"
    ],
    "short_name": "MetaMask",
    "update_url": "https://clients2.google.com/service/update2/crx",
    "version": "10.16.1"
}

Many of web extensions are still using manifest version 2, so many extension developers are pushing to finish manifest version 3 work!

Recent Features

  • By
    Create a CSS Flipping Animation

    CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's...

  • By
    CSS vs. JS Animation: Which is Faster?

    How is it possible that JavaScript-based animation has secretly always been as fast — or faster — than CSS transitions? And, how is it possible that Adobe and Google consistently release media-rich mobile sites that rival the performance of native apps? This article serves as a point-by-point...

Incredible Demos

  • By
    Fade Images with MooTools LazyLoad

    I recently received an email from a MooTools developer asking a great question about my LazyLoad class: "I'm using your LazyLoad MooTools plugin (which is great, by the way). I have been trying to figure out how to modify it so that once an image scrolls into...

  • By
    Build a Toggling Announcement Slider Using MooTools 1.2

    A few of my customer have asked for me to create a subtle but dynamic (...I know...) way for them to advertise different specials on their website. Not something that would display on every page, but periodically or only the homepage. Using a trick...

Discussion

  1. zakius

    Mv3 is another step in making extensions even less capable
    Chromium Mv2 and WebExtensions already barely can do anything and mostly are glorified userscripts and bookmarklets, with no persistent background pages and changed web request API it’ll only get worse

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!