欢迎 What's new in Chrome extensions Get help with Chrome extensions API reference Samples
欢迎 What's new in Chrome extensions Get help with Chrome extensions API reference Samples

示例

Published on Updated on

Overview

The Extensions sample GitHub repository provides examples of extensions that address various use cases and call appropriate Chrome APIs. Use these to learn how extensions work or as a starting point for building your own extensions.

Browse by category

The examples are currently located under the following directories:

api-samples/
Extensions designed to demonstrate the capabilities of a specific API. For example, the Action API example showcases extension IU elements such as the popup, tooltip, and badges among others.
functional-samples/sample...
Complete extensions that implement all the basic features for a given purpose.
functional-samples/tutorial...
Examples covered in the tutorials. A few examples include Tabs manager, Focus mode, and Reading time.
functional-samples/cookbook...
Examples demonstrating a particular concept.
functional-samples/reference...
Examples linked to documentation on this site.

💡 TIP: How can I find examples of a particular API quickly?

To find all examples of a specific Chrome API use Github's search engine to look for "chrome.NAME_OF_API" in this repository. The following example searches for all uses of "chrome.tabs":

Searching for chrome.tabs in the extension Github repository
Chrome.tabs search in the extension Github repository.

Try them out

To test these examples in your local machine, follow these steps:

  1. Clone the repository.
  2. Navigate to the directory of the extension you want to try.
  3. Load your extension locally.

Many samples have a README.md with instructions on how the extension works. (We are working to add READMEs to all samples.) Read the instructions carefully; each extension is different. For example, some extensions run by clicking on the extension icon, while others run automatically but only run on specific sites.

Contributing samples

If you encounter any problems with an example, let us know by posting an issue. If you want to submit a new extension, check out the Contributing Guide to find out how to submit a new example to this collection.

Updated on Improve article

We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.