- Create a new directory for your plugin: Create a new directory on your computer and name it after your plugin.
- Create a manifest file: In the new directory, create a file named
manifest.json
. This file contains the metadata for your plugin, including its name, version number, and permissions. - Define the manifest file: Open the
manifest.json
file in a text editor and define the basic properties of your plugin. For example, the following code defines a basic manifest file for a Chrome plugin:
jsonCopy code{
"manifest_version": 2,
"name": "My Chrome Plugin",
"version": "1.0",
"description": "A basic Chrome plugin",
"permissions": ["activeTab"]
}
This manifest file defines the name, version, and description of the plugin, and also specifies that it requires permission to access the active tab.
- Create a background script: In the same directory as the
manifest.json
file, create a new file namedbackground.js
. This file will contain the code that runs in the background of your plugin. - Define the background script: Open the
background.js
file in a text editor and define the basic properties of your plugin. For example, the following code defines a basic background script that listens for clicks on the browser action icon and displays a message:
chrome.browserAction.onClicked.addListener(function(tab) {
alert('Hello, world!');
});
This background script listens for clicks on the browser action icon and displays a message when clicked.
- Load the plugin in Chrome: To load the plugin in Chrome, open the Chrome browser and go to the Extensions page. Enable Developer mode and click the Load unpacked button. Select the directory that contains your plugin files and click Open.
Your basic Chrome plugin is now loaded in Chrome and ready to use. When you click the browser action icon, it should display a message.