How To Make A Chrome Addon

16 min read

Introduction

Creating a Chrome addon (also known as a Chrome extension) is a rewarding skill that lets you customize your browsing experience, automate repetitive tasks, or even build a product that others can use. Whether you’re a developer looking to add value to the Chrome Web Store or a curious learner wanting to understand how web technologies integrate with the browser, this guide walks you through the entire process—from the initial idea to a publishable package. By the end of this article you’ll know exactly how to make a Chrome addon that follows Manifest Version 3 guidelines, passes security checks, and is ready for users worldwide Simple as that..

Understanding Chrome Extensions

A Chrome extension is essentially a small web application that runs inside the Chrome browser. It consists of several components that work together: a manifest file, background scripts, content scripts, a popup UI, and optionally an options page. These components are packaged into a single .zip file and installed via Chrome’s extension management page. The manifest file (usually named manifest.json) tells Chrome what permissions the extension needs, which scripts to run, and how the extension should appear in the toolbar.

Key terms to remember:

  • Manifest Version 3 – the current manifest schema that emphasizes service worker‑based background scripts.
  • Permission – access to browser APIs or user data (e.g., “tabs”, “storage”).
  • Content script – runs in the context of web pages to read or modify their content.
  • Browser action – a toolbar icon with a popup that users can interact with.

Understanding these building blocks is essential before you start coding Worth keeping that in mind..

Step-by-Step Guide to Create a Chrome Addon

1. Set Up Your Project Folder

  1. Create a new folder named my‑chrome‑extension.
  2. Inside it, create the following files:
    • manifest.json
    • popup.html
    • popup.js
    • background.js (optional, for MV3)
    • content.js (optional, for page‑level scripting)

2. Write the Manifest File

The manifest is the heart of any extension. Here’s a minimal example for a browser action extension:

{
  "manifest_version": 3,
  "name": "My Awesome Extension",
  "version": "1.0",
  "description": "A simple extension that demonstrates how to make a chrome addon.",
  "action": {
    "default_popup": "popup.html",
    "default_title": "Open the popup"
  },
  "background": {
    "service_worker": "background.js"
  },
  "permissions": [
    "activeTab",
    "storage"
  ],
  "host_permissions": [
    "*://*.example.com/*"
  ]
}
  • manifest_version: set to 3 for modern extensions.
  • name, version, description: human‑readable metadata.
  • action: defines the toolbar icon and its popup.
  • background: points to a service worker script (required for MV3).
  • permissions: list any browser APIs you need.

3. Design the Popup UI (popup.html)

The popup is the user‑facing part of the extension. Keep it simple and responsive:




  
  My Extension Popup
  


  

Chrome Addon Demo

Click the button to get the current tab’s URL:

4. Add Interactivity (popup.js)

Connect the UI to the browser API:

document.addEventListener('DOMContentLoaded', () => {
  const button = document.getElementById('getUrl');
  const result = document.getElementById('result');

  button.Consider this: addEventListener('click', async () => {
    // Get the active tab in the current window
    const [tab] = await chrome. tabs.query({ active: true, currentWindow: true });
    if (tab) {
      result.textContent = `URL: ${tab.And url}`;
    } else {
      result. textContent = 'No active tab found.

You'll probably want to bookmark this section.

This script uses the `tabs` permission to query the active tab and displays its URL inside the popup.

### 5. Implement Background Logic (`background.js`)  
Background scripts run independently of the UI and can handle events like when the extension is installed or when a user clicks the toolbar icon. For a simple example:

```javascript
// Listen for when the extension is installed or updated
chrome.runtime.onInstalled.addListener((details) => {
  if (details.reason === 'install') {
    // Open a welcome page or set initial storage
    chrome.storage.local.set({ welcomeShown: true });
  }
});

// Handle messages from the popup
chrome.runtime.onMessage.type === 'getCurrentTab') {
    chrome.addListener((message, sender, sendResponse) => {
  if (message.tabs.

### 6. Optional Content Script (`content.js`)  
If you need to read or modify webpage content, inject a content script. Take this: to highlight all links on a page:

```javascript
// content.js
const links = document.querySelectorAll('a');
links.forEach((link, index) => {
  link.style.borderBottom = '2px solid red';
  link.title = `Link #${index + 1}: ${link.textContent.trim()}`;
});

Declare the content script in the manifest:

"content_scripts": [
  {
    "matches": [""],
    "js": ["content.js"]
  }
]

7. Test the Extension Locally

  1. Open Chrome and work through to chrome://extensions.
  2. Enable Developer mode (top‑

corner) toggle in the top-right area. Once enabled, additional buttons will appear near the top of the page. Click Load unpacked, then manage to and select the folder containing your extension files (specifically the one holding your manifest.In real terms, json). If the configuration is valid, Chrome will load the extension and display its icon in the toolbar.

To verify functionality, click the extension icon to open the popup, then press Get URL. You should see the current page address displayed in the result paragraph. Additionally, if the content script is active, every hyperlink on the current page will be underlined in red,

After you click the extension’s toolbar icon, you should see the popup’s “Get URL” button become active. Pressing it triggers the popup script to send a message to the background page, which in turn queries the active tab and returns its URL. The result appears instantly in the designated <p id="result"> element. If the background listener isn’t responding, open the DevTools for the background script (chrome://extensions → “Details” → “Service worker” → “Inspect background page”) and verify that the onMessage handler is correctly registered And that's really what it comes down to. Surprisingly effective..

Verifying the Content Script

If the content script is loaded, you’ll notice that every <a> element on the page now has a red underline and a tooltip showing its index. To confirm this behavior without manually inspecting each link, you can add a quick debug step in the popup: