在C ++中使用NPAPI开发Chrome扩展 [英] Developing Chrome Extensions Using NPAPI in C++

查看:171
本文介绍了在C ++中使用NPAPI开发Chrome扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C ++开发一个简单的Chrome扩展,使用NPAPI,它可以将当前页面的HTML内容转储到文件上。我在开发插件/扩展方面没有太多的专业知识。 http://code.google.com/chrome/extensions/getstarted.htmlrel =noreferrer> http://code.google.com/chrome/extensions/getstarted.html



<2> - 创建一个NPAPI插件...
http://colonelpanic.net/2009/03/building-a-firefox-plugin-part-one/



3 - 在您的扩展的清单中添加插件...

 plugins:[
{ path:your_npapi_plugin.dll}
],

4 - 背景页面创建插件

 < script> 
var plugin = document.getElementById(MyNPAPIPluginId);
...
< / script>

5 - 创建一个JavaScript,您将用作每个页面上注入的内容脚本。
在该脚本中与您的npapi脚本对象进行通信并完成您想要完成的工作。





我如何获得MyNPAPIPluginId的值?我所有的就是DLL的名称?


当您添加插件的标签时,在您的背景页面上,将ID

 < embed type =application / my-plugin-mimetypeid =MyNPAPIPluginId> 

在Windows上,在DLL的资源文件上添加MIMEType,添加一个条目:

  VALUEMIMEType,application / my-plugin-mimetype


I want to develop a simple Chrome extension in C++, using NPAPI, which does the job of dumping the HTML content of the current page onto a file. I don't have much expertise in developing plugins/extensions. How do I get started on this?

解决方案

1 - Create a Extension... http://code.google.com/chrome/extensions/getstarted.html

2 - Create a NPAPI plugin... http://colonelpanic.net/2009/03/building-a-firefox-plugin-part-one/

3 - On the manifest of your extension add the plugin...

"plugins": [
    { "path": "your_npapi_plugin.dll" }    
  ],

4 - On your extension background page create the plugin

<script>
var plugin = document.getElementById("MyNPAPIPluginId");
...
</script>

5 - Create a javascript that you will use as a content script injected on every page. On that script communicate with your npapi scriptable object and do the work you want to do.


How do I get the value of MyNPAPIPluginId? All I have is the name of the DLL?

On your background page when you add the tag of your plugin, you place the id

<embed type="application/my-plugin-mimetype" id="MyNPAPIPluginId">

On Windows you add the MIMEType on the resource file of the DLL, add a entry with:

VALUE "MIMEType", "application/my-plugin-mimetype"

这篇关于在C ++中使用NPAPI开发Chrome扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆