This document provides an overview of chrome extension development, including the different types of extensions, development and testing process, and deployment to the Chrome Web Store. It discusses the common extension architectures like browser actions, background scripts, content scripts, and permissions needed to access Chrome APIs. The development process involves creating a project structure with a manifest file, writing background and content scripts, testing features locally, and deploying the extension.
9. Background task
A single long-running script to manage some task or state
Only one instance is active per extension
Background page or event page??
Persistent: true // it’s background page
Persistent: false // it’s event page
10. Content script
Run in the context of web pages
Can read details of the web pages the browser visits, or make changes to them
Multiple instance(1 per tab) per extension
Cannot call some chrome.* API
Cannot access variables/functions defined by web pages
16. Permission and chrome.* API
API document
https://developer.chrome.com/extensions/api_index
Some API need extra permission
Chrome.management need management permission
17. chrome.* API
Three groups
User interface
Browser action, page action
Control browser
Windows, tabs, bookmakrs, history, cookies
Communicate with server
Content script, XHR
18. Chrome.runtime API
retrieve the background page, return details about
the manifest, and listen for and respond to events in
the app or extension lifecycle
19. Chrome.activeTab API
interact with the browser's tab system
executeScript
Injects JavaScript code into a page
insertCSS
Injects CSS into a page