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
    LightFace:  Facebook Lightbox for MooTools

    One of the web components I've always loved has been Facebook's modal dialog.  This "lightbox" isn't like others:  no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much."  With Facebook's dialog in mind, I've created LightFace:  a Facebook lightbox...

  • By
    fetch API

    One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest, wasn't really made for what we've been using it for.  We've done well to create elegant APIs around XHR but we know we can do better.  Our effort to...

Incredible Demos

  • By
    Create Twitter-Style Dropdowns Using jQuery

    Twitter does some great stuff with JavaScript. What I really appreciate about what they do is that there aren't any epic JS functionalities -- they're all simple touches. One of those simple touches is the "Login" dropdown on their homepage. I've taken...

  • By
    JavaScript Speech Recognition

    Speech recognition software is becoming more and more important; it started (for me) with Siri on iOS, then Amazon's Echo, then my new Apple TV, and so on.  Speech recognition is so useful for not just us tech superstars but for people who either want to work "hands...

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!