为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

谷歌浏览器插件开发快速入门

2013-04-24 2页 doc 26KB 43阅读

用户头像

is_682488

暂无简介

举报
谷歌浏览器插件开发快速入门插件开发流程 1.开发语言和软件   开发语言就是Javascript,还需要HTML和CSS的一些知识用以显示界面。开发软件选择一款自己熟悉的纯文本编辑器就可以了. 2.设计插件   一个完整的插件是由4个部分组成,分别是manifest.json、.js文件、图标和HTML文件,设计插件就是设计这4类文件。当然还可以视需要添加其他的文件进去。 *manifest.json的作用是定义插件的属性,例如名称、版本、类型等; *HTML文件具体实现插件的功能,插件要实现什么功能全靠这个文件; *js文件是一个跟浏览器互动的...
谷歌浏览器插件开发快速入门
插件开发 1.开发语言和软件   开发语言就是Javascript,还需要HTML和CSS的一些知识用以显示界面。开发软件选择一款自己熟悉的纯文本编辑器就可以了. 2.设计插件   一个完整的插件是由4个部分组成,分别是manifest.json、.js文件、图标和HTML文件,设计插件就是设计这4类文件。当然还可以视需要添加其他的文件进去。 *manifest.json的作用是定义插件的属性,例如名称、版本、类型等; *HTML文件具体实现插件的功能,插件要实现什么功能全靠这个文件; *js文件是一个跟浏览器互动的脚本,是连接浏览器和插件的桥梁。需要注意的是,这个脚本文件的执行环境是在manifest里面指定的页面,亦即它像病毒一样注入到原始网页上面去执行,但是它不能访问原始网页的JS变量、数等任何代码,只允许通过DOM来交互,它也不能只用除chrome.extention及其派生以外的API; *图标的格式为PNG; *Optional: 其它被添加进来的文件的引用遵循一般的网页开发原则,比如: 3.载入插件   设计好上面几个文件后,就可以将插件载入浏览器中试用一下。首先将它们整理到同一个文件夹中,然后在Chrome的工具栏中选择“扩展程序”,进入扩展管理页,在右侧选择“开发人员模式”,再点击“载入正在开发的扩展程序”按钮,定位到这个文件夹,将整个文件夹载入Chrome中。 4.发布插件   插件试用没有问题后,不妨将它发布出去让更多人使用。首先将插件所在的文件夹压缩成一个ZIP文件。然后再到扩展管理页,点击右下角的“获得更多扩展程序”链接,进入Chrome官方插件下载页面,在这个网页的左下角,你能看到“发布扩展程序”的链接,点击链接,上传ZIP压缩文件、添加插件的使用说明和截图,就可以发布插件了。 ***************************************************************************************************** Basic: Each extension can have at most one browser action or page action. Choose a browser action when the extension is relevant to most pages. Choose a page action,when the extension's icon should appear or disappear, depending on the page. The manifest file: Content scripts: If your extension needs to interact with web pages, then it needs a content script. A content script is some JavaScript that executes in the context of a page that's been loaded into the browser. Think of a content script as part of that loaded page, not as part of the extension it was packaged with (its parent extension).However, the content script can also communicate with its parent extension. Content scripts execute in a special environment called an isolated world. They have access to the DOM of the page they are injected into, but not to any JavaScript variables or functions created by the page. It looks to each content script as if there is no other JavaScript executing on the page it is running on. The same is true in reverse: JavaScript running on the page cannot call any functions or access any variables defined by content scripts. Although the execution environments of content scripts and the pages that host them are isolated from each other, they share access to the page's DOM. If the page wishes to communicate with the content script (or with the extension via the content script), it must do so through the shared DOM. Using the chrome.* APIs: In addition to having access to all the APIs that web pages and apps can use, extensions can also use Chrome-only APIs (often calledchrome.* APIs) that allow tight integration with the browser. Unless the doc says otherwise, methods in the chrome.* APIs are asynchronous: they return immediately, without waiting for the operation to finish. If you need to know the outcome of an operation, then you pass a callback function into the method. This feature is very important, because it allows downloads to start in another thread instead of waiting the downloads to finish, for example. ***************************************************************************************************** 注释及说明: *DOM(文档对象模型): 它将HTML或者XML文档和网络编程语言(脚本语言)连接了起来,所有程序员可用的属性、方法和事件都被组织为对象的形式,可以通过脚本访问(亦即可以被API使用),包括用JavaScript或者其它脚本语言编写的脚本,因为DOM被设计成独立于任何编程语言的结构。
/
本文档为【谷歌浏览器插件开发快速入门】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索