chrome 扩展 插件
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
只回答业务咨询
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
chrome 有2种扩展 1.Browser Action;2.page actions
popup.html中定义的Javascript变量会在popup.html页面关闭时被释放,
background.html可以保存一些一直需要使用的变量的作用,这里定义的javascript变量会在Chrome浏览器生命期中一直存在,可以把要一直存在的数据保存在这里。
Chrome扩展就是几个网页,那么代码当然就是网页的JavaScript
google chrome api: http://developer.chrome.com/extensions/api_index.html
chrome.browserAction http://developer.chrome.com/extensions/browserAction.html
{If you want to create an icon that isn't always visible, use a page action instead of a browser action. }
chrome npapi: http://developer.chrome.com/extensions/npapi.html
stackoverflow: http://stackoverflow.com/questions/2652094/start-an-external-application-from-a-google-chrome-extension
simple-get git: https://github.com/repinel/SimpleGet
extensions/samples: http://developer.chrome.com/extensions/samples.html
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文件 (可选,非必须)
任何其他你需要的文件(比如图片)
Chrome扩展能做什么呢?我们会发现有些扩展在Chrome地址栏右侧区域增加一个图标。还有些扩展能够和浏览器的一些元素(如书签、tab导航标签)交互。扩展还可以和web页面交互,甚至是从web服务器获取数据。
每个扩展是 一个.crx文件(类似zip的 压缩文件),由下列文件组成
一个manifest文件(主文件,json格式)
至少一个HTML文件(主题可以没有HTML文件)
JavaScript文件 (可选,非必须)
任何其他你需要的文件(比如图片)
工作原理
读取用户计算机数据(NPAPI Plugins)
这个功能要用到dll(动态链接库)知识,可以启动用户电脑的程序,删除用户文件等功能。。相当于一个小Windows程序。利用Chrome提供的方法可以让扩展的后台页面与你的dll通信。
这些就API文档里的Implementation部分
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,这意味着您的分机可以加载插件。
-
Add a section to your extension's
manifest.json
that describes where to find the plugin, along with other properties about it:12345678{"name": "My extension",...<b>"plugins": [{ "path": "content_plugin.dll", "public": true },{ "path": "extension_plugin.dll" }]</b>,...}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.
-
Create an HTML file that loads your plugin by mime-type. Assuming your mime-type is "application/x-my-extension":
1234<embed type="application/x-my-extension" id="pluginId"><script>var plugin = document.getElementById("pluginId");var result = plugin.myPluginMethod(); // call a method in your pluginconsole.log("my plugin returned: " + result);</script>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
学习日记,兼职软件设计,软件修改,毕业设计。
本文出自 学习日记,转载时请注明出处及相应链接。
本文永久链接: https://www.softwareace.cn/?p=47
8条评论
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!
At this time I am going to do my breakfast, when having my breakfast coming yet again to read further news.
Hi there, after reading this remarkable piece of writing i
am as well delighted to share my experience here
with friends.
Whаt’s up, I log on to your new stuff on a regular basis. Your humoristic style is awesome, keep it up!
admin 回复:
二月 19th, 2013 at 下午 5:49
thank you
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
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.
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.