Rosegarden gives you the promises for writing cross platform web extensions on Chrome and other browsers missing the promise based API.
This repository is archived, because the new promisified Chrome webextension manifest V3 APIs do not work well with this library.
I know Mozilla provides webextension-polyfill, but I find even that too complicated.
With my Spellbook bookmark browser extension I promisified the
required callback based methods from Chrome API and checked the
chrome.runtime.lastError
. Eventually I promisified the whole API,
while planning on writing another cross platform browser extension.
I have used only bookmarks and tabs APIs, so beware when using other APIs, in case they differ between Firefox and Chrome.
import { browser } from 'rosegarden'
Then just use that browser object as you would use the Mozilla's promise based WebExtension API!
It just gives the global browser object on Firefox, but on Chrome it gives a promisified version of the chrome global object as browser. The browser object has chrome as prototype, so everything should work as expected as long as the APIs work in a similar way.
pnpm install
pnpm run dev
Builds the library into the dev
directory.
pnpm run build
Builds the library into the dist
directory.
Copyright © 2018–2022 Peter Hillerström and contributors
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.