Extensions

View as Markdown

An extension adds browser capabilities to a runtime. Upload a packed .crx or import one from the Chrome Web Store, then load it into a runtime by id.

Import from the Chrome Web Store

1const extension = await bctrl.browserExtensions.import({
2 url: "https://chrome.google.com/webstore/detail/.../abcdefg",
3 name: "uBlock Origin",
4});

Upload a package

Pass the extension as a Blob. It must be a packed .crx - that is the only format supported today. name is optional and defaults to the manifest name.

1const file = new Blob([crxBytes], { type: "application/x-chrome-extension" });
2const extension = await bctrl.browserExtensions.upload({ file, name: "ad blocker" });

List, read, delete

1const { data } = await bctrl.browserExtensions.list();
2const one = await bctrl.browserExtensions.get(extension.id);
3
4await bctrl.browserExtensions.update(extension.id, { name: "ad blocker" });
5await bctrl.browserExtensions.delete(extension.id);

Load into a runtime

Reference extensions by id in runtime configuration:

1const runtime = await bctrl.runtimes.create({
2 type: "browser",
3 name: "main",
4 config: { extensionIds: [extension.id] },
5});

Next