TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Rosegarden (1.7kb): Cross browser Promise based WebExtension development

1 点作者 peterhil超过 3 年前

2 条评论

peterhil超过 3 年前
Rosegarden gives you the promises for writing cross platform webextensions on Chrome and other browsers missing the promise based API.<p>## Rationale<p>I know Mozilla provides webextension-polyfill, but I find even that too complicated.<p>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.<p>I have used only bookmarks and tabs APIs, so beware when using other APIs, in case they differ between Firefox and Chrome.<p>## Usage<p>import { browser } from &#x27;rosegarden&#x27;<p>Then just use that browser object as you would use the Mozilla&#x27;s promise based WebExtension API!<p>It just gives the global object on Firefox, but on Chrome it gives a promisified version of the chrome global object. The browser object has chrome as prototype, so everything should work as expected as long as the APIs work in a similar way.
peterhil超过 3 年前
Here is a single commit that shows what this library basically does:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;peterhil&#x2F;spellbook&#x2F;commit&#x2F;d3dd9626ef597922930b28f4dd25abc601e0f3af" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;peterhil&#x2F;spellbook&#x2F;commit&#x2F;d3dd9626ef59792...</a>