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

Incredible Demos

  • By
    Optimize Your Links For Print Using CSS — Show The URL

    When moving around from page to page in your trusty browser, you get the benefit of hovering over links and viewing the link's target URL in the status bar. When it comes to page printouts, however, this obviously isn't an option. Most website printouts...

  • By
    Modal-Style Text Selection with Fokus

    Every once in a while I find a tiny JavaScript library that does something very specific, very well.  My latest find, Fokus, is a utility that listens for text selection within the page, and when such an event occurs, shows a beautiful modal dialog in...

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!