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
    CSS Filters

    CSS filter support recently landed within WebKit nightlies. CSS filters provide a method for modifying the rendering of a basic DOM element, image, or video. CSS filters allow for blurring, warping, and modifying the color intensity of elements. Let's have...

  • By
    Animated 3D Flipping Menu with CSS

    CSS animations aren't just for basic fades or sliding elements anymore -- CSS animations are capable of much more.  I've showed you how you can create an exploding logo (applied with JavaScript, but all animation is CSS), an animated Photo Stack, a sweet...

Incredible Demos

  • By
    Build a Calendar Using PHP, XHTML, and CSS

    One of the website features my customers love to provider their web users is an online dynamic calendar. An online calendar can be used for events, upcoming product specials, memos, and anything else you can think of. I've taken some time to completely...

  • By
    MooTools PulseFade Plugin

    I was recently driven to create a MooTools plugin that would take an element and fade it to a min from a max for a given number of times. Here's the result of my Moo-foolery. The MooTools JavaScript Options of the class include: min: (defaults to .5) the...

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!