关于 Firefox 附加组件/扩展的向后兼容性问题

发布于 2024-12-07 20:18:29 字数 933 浏览 1 评论 0 原文

背景信息

过去一周,我一直在摆弄 Chrome 扩展程序,并且在创建扩展程序时没有遇到任何问题。太棒了,Chrome 使开发过程变得非常容易学习,而且,嗯……很简单!

现在我想为尽可能多的浏览器创建这个扩展,所以我决定下一步使用 Firefox。

真是一团糟!到目前为止,这些文档除了让我头疼、浪费我的时间之外什么也没做,非常复杂,而且通常没有条理。

我已经设法找到了一个简单扩展的代码示例,我认为我可以将其用作起点,并开始搞乱 - 好吧...

我了解到这个示例扩展不适用于 Firefox 4 以下的任何版本,因为它使用引导技术使扩展无需重新启动浏览器即可安装。呃……

现在我们来回答我的问题:

  1. 是否可以为 Firefox 7 开发一个可以与以前版本的 Firefox 一起使用的扩展?我什至不关心 Firefox 4 之前的任何内容,如果那是无需重新启动安装的截止点。很高兴知道我花这么多时间制作的东西能够在用户下次被提示升级时持续工作一个多星期。

  2. 反过来怎么样?我可以创建与 Firefox 3.5 到 Firefox 7 兼容的扩展吗?我意识到这需要重新启动才能安装,但如果无论版本如何都能产生有效的扩展,那就可以接受。

  3. 任何有这方面经验的人都可以分享一下我在这里所做的事情吗?这似乎是一个开发平台的噩梦,我将不断修复我的扩展。

最后一条相关信息:

我正在开发的扩展纯粹基于 javascript - 这个东西应该工作(我认为?),因为它只依赖于一个功能“内容脚本” “此时版本之间的实现确实不应该改变......对吧?

那么我到底错过了什么?如何创建可在所有版本的浏览器中运行的易于管理的 Firefox 扩展?

谢谢大家! :)

Background info:

Over the past week, I have been messing around with Chrome extensions and had no problem creating my extension. Great, Chrome rocks for making the development process very easy to learn, and, well... just easy!

Now I have it in my mind that I'd like to create this extension for as many browsers as I can, so I decided on Firefox next.

What a mess! There documentation has done nothing but give me a headache and waste my time so far, VERY convoluted and just generally unorganized.

I have managed to locate a code sample for a simple extension that I think I can use as a starting point and have begun messing around with - fine...

I have learned that this sample extension will not work with anything less than Firefox 4, as it uses the bootstrap technique to make the extension installable without a browser restart. Ughhhhhh....

Now we arrive at my questions:

  1. Is it possible to develop an extension for Firefox 7 that will work with previous versions of Firefox? I don't even care about anything prior to Firefox 4, if that's the cutoff point for restart-less installations. It would be nice to know that what I am spending all this time making will work consistently and for more than a week when the user is prompted to upgrade next.

  2. How about the reverse? Can I create an extension that is compatible with Firefox 3.5 through Firefox 7? I realize it would require a restart to install, but that would be acceptable if it resulted in a working extension regardless of the version.

  3. Can anyone with experience on this stuff share a bit of what I'm getting myself into here? It seems like this is a nightmare of a platform to develop on, and that I will be constantly fixing my extension.

One last piece of relevant information:

The extension I am developing is purely javascript based - this stuff should work (I think?) because it's dependent on just one feature "content scripts" that really shouldn't be changing in implementation between versions at this point... right?

So what exactly am I missing? How do you create easily manageable Firefox extensions that will work in all versions of the browser?

Thanks everyone! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一生独一 2024-12-14 20:18:29

您必须区分“传统”扩展程序和使用附加 SDK。前者的功能要强大得多,因为它们可以直接访问浏览器使用的所有 API,但这也是它们编写起来更复杂以及文档相当无序的原因(您可以做很多事情,远远超过 Chrome 的功能)。随着浏览器的变化,它们也更有可能崩溃。另一方面,附加 SDK 为您提供了有限的 API,就像 Chrome 一样。附加组件 SDK 目前支持从 Firefox 4 开始的所有版本(是的,因为无需重新启动安装),并承诺浏览器更改只需要使用较新版本的附加组件 SDK 重新编译您的附加组件。事实上,重新编译 可能会自动发生未来 用于 addons.mozilla.org 上托管的附加组件。关于你的问题:

是否可以为 Firefox 7 开发一个可与以前版本的 Firefox 配合使用的扩展?

当然是。附加组件 SDK 目前将您的附加组件标记为与 Firefox 4 Beta 7 和 Firefox 8 Alpha 1 之间的任何组件兼容。即使与传统附加组件一样 - 从 Firefox 4 开始,特定浏览器版本之间的差异也相当小,大多数情况下在所有这些工作中工作。您还可以保持与 Firefox 3.x 的兼容性,但根据您的操作,这可能需要一些努力。重要信息:

反过来怎么样?我可以创建与 Firefox 3.5 到 Firefox 7 兼容的扩展吗?

你走哪条路并不重要。不过,我不建议在 Firefox 3.x 支持上花费太多时间。由于不再支持 Firefox 3.5,唯一相关的版本是 Firefox 3.6。根据我的附加组件的统计,大约 18% 的 Firefox 用户继续使用它。在接下来的几个月中,这一比例将显着降低,特别是当 Mozilla 宣布该分支生命周期结束时。因此,对于新的附加组件来说,支持它通常是不合理的。

任何有这方面经验的人都可以分享一下我在这里所做的事情吗?

取决于您的附加组件的复杂程度。鉴于您正在开发相当于 Chrome 扩展程序,您很可能会使用附加 SDK,这意味着不会有任何兼容性问题。与传统的附加组件一样,不依赖于一些晦涩的实现细节的简单附加组件通常也不会在保持兼容方面遇到任何问题(我有两个附加组件,自 Firefox 3.5 以来不需要进行任何调整) 。当然,深入系统的附加组件问题更大。

You have to distinguish between "traditional" extensions and extensions built with the Add-on SDK. The former are far more powerful given that they have direct access to all APIs the browser uses - but that's also the reason why they are more complicated to write and why the documentation is rather unordered (there are simply very many things that you could do, far more than you could with Chrome). They are also more likely to break as the browser changes. The Add-on SDK on the other hand gives you a limited API much like Chrome. The Add-on SDK currently supports everything from Firefox 4 onwards (yes, because of restartless installation), with the promise that browser changes will merely require your add-on to be recompiled with a newer version of the Add-on SDK. In fact, that recompiling will likely happen automatically in future for add-ons hosted on addons.mozilla.org. On to your questions:

Is it possible to develop an extension for Firefox 7 that will work with previous versions of Firefox?

Sure it is. The Add-on SDK currently marks your add-on as compatible with anything between Firefox 4 Beta 7 and Firefox 8 Alpha 1. Even as traditional add-ons go - starting with Firefox 4 the differences between particular browser versions are rather small, most things work in all of them. You can also stay compatible with Firefox 3.x but depending on what you do it might require some effort. Important information:

How about the reverse? Can I create an extension that is compatible with Firefox 3.5 through Firefox 7?

It doesn't matter which way you go. I wouldn't recommend spending much time on Firefox 3.x support however. With Firefox 3.5 no longer supported the only relevant version is Firefox 3.6. According to the statistics of my add-ons roughly 18% of the Firefox users continue using it. In the next few months this percentage will get significantly smaller, especially when Mozilla announces end-of-life for this branch. So for a new add-on supporting it is usually not justified.

Can anyone with experience on this stuff share a bit of what I'm getting myself into here?

Depends on how complicated your add-on will be. Given that you are developing an equivalent to a Chrome extension, you will most likely be using the Add-on SDK which means that there won't be any compatibility problems. As traditional add-ons go, simple add-ons that don't rely on some obscure implementation details also typically don't have any trouble staying compatible (I have two add-ons that didn't need a single adjustment since Firefox 3.5). Add-ons that go deep down into the system are more problematic of course.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文