Chrome扩展中的重要概念:Content Scripts
来源:互联网 发布:内网外网一键切换软件 编辑:程序博客网 时间:2024/05/16 02:06
If you want your extension to interact with web pages, you need a content script.
一直在关注如何做Chrome的扩展,Chrome如何支持扩展。以前就看过Turorial中的HelloWorld,觉得这么简单,能干些什么啊。今天看了nkGestures的源码,然后又重新看了一下Chrome Extension的开发文档,觉得Content Script的概念比较重要,在此把我的理解记录下。
Chrome的扩展基本是基于Java Script的(当然可以通过其它方法调用C/C++代码),这样就为以后不同平台下的浏览器做好了准备,果然是Google。
Chrome允许在打开窗口,TAB或其它事件的情况下执行扩展中的代码,这部分代码就叫做:Content Scripts。Content Scripts are JavaScript files that run in the context of web pages. By using the standard Document Object Model (DOM), they can read details of the web pages the browser visits, or make changes to them.同时,Content Scripts 可以通过Channel和Extension进行通讯。
Content scripts can communicate with their parent extension using message passing. The content script opens a channel to the extension using the chrome.extension.connect() method and then sends messages back and forth to it. The messages can contain any valid JSON object (null, boolean, number, string, array, or object).
The parent extension can also open a channel to a content script in a given tab by callingchrome.tabs.connect(tabId).
When a channel is opened from a content script to an extension, the onConnect event is fired in all views in the extension. Any view can receive the event. The event contains a Port object, which can be used by the extension view to communicate back to the content scrip
- Chrome扩展中的重要概念:Content Scripts
- Chrome的Content Scripts扩展开发
- Chrome 56 扩展开发入门:Content Scripts
- chrome扩展之content scripts与web pages 交互
- Chrome浏览器扩展开发系列之十二:Content Scripts
- chrome content scripts 开发
- 整数中的重要概念
- libjingle中的重要概念
- Camel中的重要概念
- 神经网络中的重要概念
- AOP中的几个重要概念
- 计算机网络中的几个重要概念
- 操作系统中的一些重要概念
- HEVC中的几个重要概念
- JavaWeb开发中的重要概念
- Java中的一些重要概念
- rtp/rtcp中的一些重要概念
- Analysis Services MDX 中的重要概念
- 通过构造器注入IOC的依赖关系
- Asp.Net 上传大文件专题(4)--利用ajax技术显示上传进度
- 对话框程序设置Class Name
- 取2个日期的天数
- 进程的创建和管理
- Chrome扩展中的重要概念:Content Scripts
- ASP.NET2.0中给GridView动态添加模板列并自动绑定数据
- wxWidgets调用指定程序打开文件代码
- ini配置文件常用的四个函数
- 命令行的快速使用
- 域名批量查询工具实测
- 公钥和私钥的理解
- 咋就成负的了呢
- 如梦令. 失眠