chrome 扩展 插件

作者: littlesu 分类: chrome 发布时间: 2013-01-16 15:37 ė22,773 浏览数 68条评论
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
 chrome 有2种扩展 1.Browser Action;2.page actions

 

Chrome扩展就是几个网页,那么代码当然就是网页的JavaScript 
有帮助的网页:http://blog.neverbest.com/?p=276
{If you want to create an icon that isn't always visible, use a page action instead of a browser action. }
Browser Plugins vs Extensions – the difference  http://colonelpanic.net/2010/08/browser-plugins-vs-extensions-the-difference/
An extension could contain a plugin, but a plugin can’t contain an extension
 
半路出现个这个
 
google Browser extension framework
 
一个Chrme扩展是由HTML、CSS、JavaScript、图片等文件压缩而成。扩展实际上就是一个web页面,可以用任何浏览器提供给web页面的接口,从XMLHttpRequest 到JSON ,再到HTML本地缓存都可以使用。
Chrome扩展能做什么呢?我们会发现有些扩展在Chrome地址栏右侧区域增加一个图标。还有些扩展能够和浏览器的一些元素(如书签、tab导航标签)交互。扩展还可以和web页面交互,甚至是从web服务器获取数据。
每个扩展是 一个.crx文件(类似zip的 压缩文件),由下列文件组成
一个manifest文件(主文件,json格式)
至少一个HTML文件(主题可以没有HTML文件)
JavaScript文件 (可选,非必须)
任何其他你需要的文件(比如图片)
 
工作原理
 
 
 
 
读取用户计算机数据(NPAPI Plugins

这个功能要用到dll(动态链接库)知识,可以启动用户电脑的程序,删除用户文件等功能。。相当于一个小Windows程序。利用Chrome提供的方法可以让扩展的后台页面与你的dll通信。

这些就API文档里的Implementation部分

2010-05-11_230436

 

 
 
Background page 和 PopUp  page

popup.html中定义的Javascript变量会在popup.html页面关闭时被释放,
background.html可以保存一些一直需要使用的变量的作用,这里定义的javascript变量会在Chrome浏览器生命期中一直存在,可以把要一直存在的数据保存在这里。
 
先在background.html中定义好变量,
 var global_email = "";
然后在popup.html中用以下方式来引用这些变量
 var bgpg = chrome.extension.getBackgroundPage();
bgpg.global_email = "somebody@domain.com";

 

 
分析 插件
 
manifest.json 主文件 Formats: Manifest Files 
 

NPAPI Plugins

 

JavaScript中调用本机二进制代码
 How to develop an NPAPI plugin is outside the scope of this document. See Mozilla's NPAPI plugin reference for information on how to do that.
 
“公共”属性指定你的插件是否可以访问一般的网页,默认值为false,这意味着您的分机可以加载插件。
 
 
  1. Add a section to your extension's manifest.json that describes where to find the plugin, along with other properties about it:

     

    The "path" property specifies the path to your plugin, relative to the manifest file. The "public" property specifies whether your plugin can be accessed by regular web pages; the default is false, meaning only your extension can load the plugin.

  2. Create an HTML file that loads your plugin by mime-type. Assuming your mime-type is "application/x-my-extension":

     

     
    This can be inside a background page or any other HTML page used by your extension. If your plugin is "public", you can even use a content script to programmatically insert your plugin into a web page.
     
     
    获取当前的页面的链接
     
    下一步封装库 fun(currentUrl);
     
     
    顺便看到个这个 LomoX常见问题
     
    qt plugin 
     
     
     


只回答业务咨询点击这里给我发消息 点击这里给我发消息

王牌软件,兼职软件设计,软件修改,毕业设计。

本文出自 王牌软件,转载时请注明出处及相应链接。

本文永久链接: http://www.softwareace.cn/?p=47

0

8条评论

  1. Darin 2013 年 2 月 9 日 下午 11:54 回复

    Thanks on your marvelous posting! I definitely enjoyed reading
    it, you can be a great author.I will make sure to bookmark your
    blog and will eventually come back in the foreseeable future.
    I want to encourage you continue your great work, have a nice holiday
    weekend!

  2. download far cry 3 2013 年 2 月 11 日 上午 8:06 回复

    At this time I am going to do my breakfast, when having my breakfast coming yet again to read further news.

  3. starcraft 2 heart of the swarm 2013 年 2 月 11 日 上午 8:23 回复

    Hi there, after reading this remarkable piece of writing i
    am as well delighted to share my experience here
    with friends.

  4. cheap viagra 2013 年 2 月 11 日 下午 1:10 回复

    Whаt’s up, I log on to your new stuff on a regular basis. Your humoristic style is awesome, keep it up!

    admin 回复:

    thank you

  5. mmafightvideos.tv 2013 年 2 月 14 日 上午 9:28 回复

    I simply couldn’t go away your website prior to suggesting that I really enjoyed the standard information a person provide for your guests? Is going to be again frequently in order to check out new posts

  6. starcraft 2 heart of the swarm 2013 年 2 月 17 日 上午 11:30 回复

    Hmm is anyone else experiencing problems with the
    images on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog.
    Any feedback would be greatly appreciated.

  7. pirater whatsapp 2013 年 4 月 13 日 下午 2:24 回复

    It is really a nice and useful piece of info. I am glad that you
    simply shared this useful info with us. Please keep us
    up to date like this. Thanks for sharing.

cheap viagra进行回复 取消回复

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">


Ɣ回顶部

无觅相关文章插件,快速提升流量