Get up and do the Chrome extension "Basic Introduction"

Source: Internet
Author: User

First of all, the extension of Chrome is not its plug-ins, many of the online say write plug-ins, in fact, are said to expand. Write extensions are not complicated, as long as there are a number of features that can be implemented based on a series of APIs provided by Chrome. There is a price to learn about the API, plus the domestic access to the Chrome website is not going well. Although 360 provides a translation document, and there are many examples, its content is still too little, some problems it still does not involve. So, there is no problem in doing a simple application, but the actual project development often does not have the useful introduction and explanation.

This series of articles will solve some practical problems, involving the following:

    • Basic Configuration
    • Content_script and Background_script
    • Use of cookies
    • Local storage
    • Ajax requests Remote Data

Bo Master is also in the study, said is also the development process of some summary, not necessarily correct, if wrong, also please forgive.

Write extension only one file is fixed, others do not have any fixed requirements, such as fixed format, fixed folder and so on. This fixed file is its configuration file, a JSON-formatted file: Manifest.json, the basic content is as follows:

Manifest.json

{    "manifest_version": 2,    "name": "My Extension",    "description": "Extension description",    "Version": "1.0"}   

This is one of the simplest files and there are 2 issues to be aware of:

    • Currently, manifest_version must be written as 2, so the rest of the numbers are not written, especially 1.
    • In JSON, the last item is not available, the number is not, or it will be enabled to fail.

These items do not need to be introduced, you should know what they are, they will appear in the extension interface, the other is useless. A true extension is certainly not the only one. It can be involved, Bo Master simple summed up into two categories:

    • Chrome browser elements, such as tab, bookmark, history, etc.
    • Page content

So, if your extension needs to be involved, you have to add it to the configuration JSON, which is the Manifest.json file, if you need to use tab:

{    "manifest_version": 2,    "name": "My Extension",    "description": "Extension description",    "Version": "1.0",    "Permissions": ["Tabs" ]}     

Permissions is allowed, it tells Chrome that the plugin is allowed to tab, or Chrome allows you to use its tab-related APIs. So, if you use bookmarks, or something else, you can write it in here. For example, we want to use agent-related APIs:

{    "manifest_version": 2,    "name": "My Extension",    "description": "Extension description",    "Version": "1.0",    "Permissions": ["Tabs", "proxy" ]}      

Proxy means that you can use agent-related APIs, such as Cookie,history, and so on, with specific reference to the official documentation

The Chrome extension does not have strict requirements for the directory, so except for Manifest.json this file must be, the others are added on demand. The directory structure can be named according to your habits, no problem.

Get up and do the Chrome extension "Basic Introduction"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.