现在的位置: 首页 > 综合 > 正文

Chrome插件开发学习笔记(一)

2013年08月29日 ⁄ 综合 ⁄ 共 2091字 ⁄ 字号 评论关闭

Chrome Plugin Guide

Summary

-          An extension is a zipped bundle of files – HTML, CSS, JS, images, and anything else you need.

-          Extensions are essentially web pages, and they can use all the APIs that the browser provides

-          Many extensions add UI to Chrome in the form of browser actions or page actions.

-          Extensions can also interact programmatically with browser such as bookmarks and tabs.

-          To interact with web pages or servers, extensions can use content scripts or cross-origin XMLHttpRequests.

1.       Choose a browser action when the extension is relevant to most pages.

2.       Choose a page action when the extension’s icon should appear or disappear

-          Each extensions has the following files:

1.       A manifest file

2.       One or more HTML files

3.       [optional] One or more JavaScript files

4.       [optional] Any other your extensions need, like images files

-          When distribute extension, the contents of the folder are packaged into a special ZIP file that has a .crx suffix.

-          You can refer to the file in your extension by relative URL. Every file in an extension is also accessible by an absolute URL like this:  chrome-extension://<extensionID>/<pathToFile>

-          extensionID is a unique identifier that the extension system generates for each extension.

 

Manifest file

-          The manifest file, called manifest.json, gives information about the extension, such as the most important files and the capabilities that the extension might use.

 

Content Scripts

-          A content script is some JavaScript that executes in the contect 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

-          Content scripts can read details of the web pages the browser visits, and they can make change to the page.(modify the DOM for the displayed web page, but cann’t modify the background page)

-          A content script can exchange messages with its parent extension.

Chrome Plugin-1

Communicaiton between pages

-          The HTML pages with in an extension often need to communicate. Because all of an extension’s pages execute in same process on the same thread, the pages can make direct function calls to each other.

-          Incognito mode promises that the window will leave no tracks. When dealing with data from incognito windows, do your best to honor this promise. (check tab.incognito property)

 

 

抱歉!评论已关闭.