有没有办法将 chrome 扩展移植到其他浏览器,而无需完全重新编写代码?我的 chrome 扩展使用browser_action命令在扩展窗口中打开“popup.html”...
更新:我发现adblockforchrome port.js并发现它对移植到 Safari 有点帮助......
有没有办法将 chrome 扩展移植到其他浏览器,而无需完全重新编写代码?我的 chrome 扩展使用browser_action命令在扩展窗口中打开“popup.html”...
更新:我发现adblockforchrome port.js并发现它对移植到 Safari 有点帮助......
Apple提供了一些关于如何将 Chrome 扩展程序移植到 Safari 的指导,但您将遇到的问题是每个浏览器都有一组不同的允许的扩展功能。即使使用 Chrome 到 Safari,也有一些您可以在 Chrome 中执行但在 Safari 中无法执行的操作,反之亦然。
Jumping in a bit late.
Our company - Slice Factory (full disclosure here!) does provide a browser extension conversion service: http://gallery.extensionfactory.com/labs/conversion/ In most cases your chrome extension will work seamlessly in FF and Safari.
The service is still in beta trial, and Firefox conversion is working better than Safari one. I can't fully disclose what's our technical solution, but this being an SO answer, I can add a few details: we have re-developed a full javascript api stack that mimics most of chrome extension APIs for Safari and Firefox; in Firefox we base our work on JetChrome. Plus we have wrappers that re-package the chrome extension adding our library and rewriting manifests and so on.
Beyond that, it's mostly a few good ideas, trial and error, and a LOT of development time.
As an example: Safari 5.1 just introduced a popup corresponding to Chrome's browser_action, but we have already an alternative solution that works for previous versions. Firefox does not support HTML5 WebSQL, but we have an API for it. We also provide a way to bring webapps to FF, and soon to Safari. The objective is to have Chrome API as a reference, and mimic it on all the other browsers.
Without pushing you towards our solution, I might add that the time to fully cover the Chrome API on both Safari and Firefox is probably not worth it - unless you plan to convert several extensions. So for just one or two extensions I would advise making your code as modular as possible, and just creating three extensions - or trying our service!
这取决于扩展的类型,但不是真的。为了更清楚地回答您的问题,您需要指定扩展的内容:修改某些页面(如用户脚本/用户样式)、扩展浏览器的功能或其他内容。
但是,有一些可移植性说明可以帮助您简化此过程:
是的,使用webextension- polyfill 的 Webextension API 是可能的。
我利用它来构建它,我只需将回调方法更改为 Promises 并使用browser.something
而不是chrome.something
调用浏览器 API。