如何编写浏览器插件?

时间:2023-01-14 16:19:39

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++.

我对为Chrome、Safari和Opera等浏览器编写浏览器插件的过程很感兴趣。我特别想到Windows,更喜欢使用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.

注意:我不是指扩展名或“插件”。我指的是一个插件,类似于Flash和adobereader如何使用插件来处理特定的内容类型。

4 个解决方案

#1


39  

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

正如其他人指出的,这些浏览器的插件是使用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.

注意:火狐浏览器和Chrome浏览器都将会默认大部分插件都是点击播放的,Chrome计划将完全淘汰NPAPI。NPAPI在这一点上是不鼓励的。

Resources for getting started with NPAPI:

开始使用NPAPI的资源:

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

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

  • FireBreath - cross-browser, cross-platform frame-work for plugins
  • FireBreath——用于插件的跨浏览器、跨平台框架工作
  • Nixysa - generate glue-code for NPAPI plugins
  • 为NPAPI插件生成胶体代码
  • JUCE - application framework also providing support for plugins
  • 应用程序框架也为插件提供支持
  • QtBrowserPlugin - Qt based browser plugin framework
  • QtBrowserPlugin - Qt的浏览器插件框架。

#2


4  

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

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

  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.

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

  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

    Nixysa。我不认为它正在积极发展。文档是贫穷。从wiki页面的评论中可以看出:https://code.google.com/p/nixysa/wiki/HelloWorldWalkThru用户根本得不到任何帮助,在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.

    JUCE。它不是专门用来创建浏览器插件的。它不支持Linux。作者认为NPAPI将会消亡,因此他没有计划支持Linux或添加新特性。

  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)

    QtBrowserPlugin。在QT 4.5之后的文档中无法找到它。换句话说,它不被维护(从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.

更新:Chrome不支持NPAPI。我认为在未来用c++编写插件会越来越难,因为缺乏浏览器的支持。

#3


2  

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

基于netscap的浏览器、Chrome、Safari和Opera使用NPAPI插件系统,您可以学习如何在https://developer.mozilla.org/en/Plugins和http://code.google.com/chrome/extensions/npapi.html中编写NPAPI插件

#4


0  

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

如果您知道Qt,那么它们就会有一些类,从而更容易实现浏览器插件。

#1


39  

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

正如其他人指出的,这些浏览器的插件是使用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.

注意:火狐浏览器和Chrome浏览器都将会默认大部分插件都是点击播放的,Chrome计划将完全淘汰NPAPI。NPAPI在这一点上是不鼓励的。

Resources for getting started with NPAPI:

开始使用NPAPI的资源:

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

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

  • FireBreath - cross-browser, cross-platform frame-work for plugins
  • FireBreath——用于插件的跨浏览器、跨平台框架工作
  • Nixysa - generate glue-code for NPAPI plugins
  • 为NPAPI插件生成胶体代码
  • JUCE - application framework also providing support for plugins
  • 应用程序框架也为插件提供支持
  • QtBrowserPlugin - Qt based browser plugin framework
  • QtBrowserPlugin - Qt的浏览器插件框架。

#2


4  

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

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

  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.

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

  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

    Nixysa。我不认为它正在积极发展。文档是贫穷。从wiki页面的评论中可以看出:https://code.google.com/p/nixysa/wiki/HelloWorldWalkThru用户根本得不到任何帮助,在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.

    JUCE。它不是专门用来创建浏览器插件的。它不支持Linux。作者认为NPAPI将会消亡,因此他没有计划支持Linux或添加新特性。

  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)

    QtBrowserPlugin。在QT 4.5之后的文档中无法找到它。换句话说,它不被维护(从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.

更新:Chrome不支持NPAPI。我认为在未来用c++编写插件会越来越难,因为缺乏浏览器的支持。

#3


2  

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

基于netscap的浏览器、Chrome、Safari和Opera使用NPAPI插件系统,您可以学习如何在https://developer.mozilla.org/en/Plugins和http://code.google.com/chrome/extensions/npapi.html中编写NPAPI插件

#4


0  

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

如果您知道Qt,那么它们就会有一些类,从而更容易实现浏览器插件。