How to get my extension’s id from JavaScript?

You can get it like this (no extra permissions required) in two different ways:

  1. Using runtime api: var myid = chrome.runtime.id;

  2. Using i18n api: var myid = chrome.i18n.getMessage("@@extension_id");

but you don’t need it for opening pages, as chrome.tabs.create() (and some others) understand relative paths.

So to open index.html from your extension folder you should just use:

chrome.tabs.create({url: "index.html"});

Leave a Comment