如何编写浏览器插件?

发布于 2024-08-28 16:57:32 字数 228 浏览 7 评论 0原文

我很好奇为 Chrome、Safari 和 Opera 等浏览器编写浏览器插件的过程。我在这里特别考虑 Windows,并且更喜欢使用 C++。

有没有详细说明该过程的工具或教程?

注意:我指的不是扩展程序或“插件”。我指的是一个类似于 Flash 和 Adob​​e Reader 具有处理特定内容类型的插件的插件。

I'm curious as to the procedure for writing browser plugins for browsers like Chrome, Safari, and Opera. I'm thinking specifically of Windows here and would prefer working with C++.

Are there any tools or tutorials that detail the process?

Note: I am not referring to extensions or 'addons'. I'm referring to a plugin similar to how Flash and Adobe Reader have plugins to handle specific content-types.

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

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

发布评论

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

评论(4

苏大泽ㄣ 2024-09-04 16:57:32

正如其他人指出的那样,这些浏览器的插件是使用 NPAPI 编写的。

注意:Firefox 和 Chrome 都会默认大多数插件立即点击播放, Chrome 计划完全淘汰 NPAPI< /a>.目前不鼓励

将 NPAPI 用于新项目。 NPAPI 入门资源:

然而 NPAPI 本身相对较低级别,但有一些工具和框架可以帮助您:

As others point out, plugins for those browser are written using the NPAPI.

Note: Both Firefox and Chrome will default most plugins to click-to-play soon, with Chrome planning to phase out NPAPI entirely. NPAPI for new projects is discouraged at this point.

Resources for getting started with NPAPI:

The NPAPI itself is however relatively low-level, but there are tools and frameworks that can help you with it:

  • FireBreath - cross-browser, cross-platform frame-work for plugins
  • Nixysa - generate glue-code for NPAPI plugins
  • JUCE - application framework also providing support for plugins
  • QtBrowserPlugin - Qt based browser plugin framework
葬シ愛 2024-09-04 16:57:32

我研究了 Georg 列出的一些框架,这是我得到的:

  1. FireBreath。我认为这几乎是最好的一个。您可以在几天内使用 FireBreath 创建跨平台浏览器插件。我确实发现了一些缺点: 它不支持 Windows 上的 utf-8 字符。例如:如果文件名中有中文字符,则无法读取该文件的内容。我相信 boost/locale 可以解决这个问题。但 FireBreath 不包含 boost/locale。是的,你可以使用外部增强,但我花了几天时间进行配置和调整,但仍然无法在 Windows 上进行编译。作者使用cmake来组织代码和子项目。而且他创建了很多bat或shell脚本和cmake宏,非常难以理解和配置。简而言之,如果你想要 FireBreath 目前没有提供的东西,你就会运气不好,很难添加新功能。

  2. 尼克希萨。我不认为它正在积极开发。文档很差。并来自维基页面的评论:https://code.google.com/p/ nixysa/wiki/HelloWorldWalkThru 我们可以知道,用户根本无法获得帮助,并且无法在 Windows 上运行它

  3. JUCE 上运行它。它并不是专门用于创建浏览器插件。它不支持 Linux。作者认为 NPAPI 即将消亡,因此没有计划支持 Linux 或添加新功能。

  4. QtBrowserPlugin。您无法在 QT 4.5 之后的文档中找到它。换句话说,它没有被维护(并从 Qt 5.0 中删除)

一旦我找到更多信息,我将更新这个答案。

更新:Chrome 放弃了 NPAPI 支持。我认为将来用 C++ 编写插件会变得越来越难,因为缺乏浏览器的支持。

I investigated some frameworks listed by Georg, here is what I get:

  1. FireBreath. I think it is almost the best one available. You can create a cross platform browser plugin with FireBreath in a few days. I did find some cons: It does not support utf-8 characters on Windows. For example: if there are Chinese characters in a file name, you cannot read the content of that file. I believe that boost/locale can resolve this issue. But FireBreath does not contain boost/locale. Yes you can use external boost, but I spent several days configuring and tweaking and still cannot get it compiling on Windows. The author uses cmake to orgnize code and sub-projects. And he created a lot of bat or shell scripts and cmake macros, it is very hard to understand and configure. In short, if you want something that FireBreath currently does not provide, you will have a bad luck, it is very hard to add new features.

  2. Nixysa. I don't think that it is being actively developed. Documentation is poor. And from the comments of the wiki page: https://code.google.com/p/nixysa/wiki/HelloWorldWalkThru We can know that users could not get help at all and were having trouble get it running on Windows

  3. JUCE. It is not specially for creating browser plugins. It does NOT support Linux. The author thinks that NPAPI is going to die so he has no plan to support Linux or add new features.

  4. QtBrowserPlugin. You can not find it in documentation later than QT 4.5. In another word, it is not maintained(and removed from Qt 5.0)

I will update this answer once I find more.

Update: Chrome dropped NPAPI support. I think in the future it becomes harder and harder to write plugins in C++ because lacks of support from browsers.

硬不硬你别怂 2024-09-04 16:57:32

基于 Netscape 的浏览器、Chrome、Safari 和 Opera 等浏览器都使用 NPAPI 插件系统,您可以在 https://developer.mozilla.org/en/Pluginshttp://code.google.com/chrome/extensions/npapi.html

Browsers like Netscape-based browsers, Chrome, Safari and Opera uses NPAPI plugin system, you can learn how to write NPAPI plugins in https://developer.mozilla.org/en/Plugins and http://code.google.com/chrome/extensions/npapi.html

溺深海 2024-09-04 16:57:32

如果您了解 Qt,那么他们有一些类可以更轻松地实现浏览器插件

If you know Qt then they have got some classes that makes it easier to implement browser plug-ins

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