Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 36 ยท Getting Started

What Are Chrome Extensions?

Learn what a Chrome extension is, what it can and cannot do, which browsers run it, and how this course teaches extensions on a site that cannot load them.

A Chrome extension is a small program, written with HTML, CSS and JavaScript, that adds features to the browser itself. A password manager, an ad blocker, a dark-mode switcher and a tab organizer are all extensions. Unlike a web page, an extension is installed into the browser and can act on many sites, react to browser events and add its own buttons, menus and panels.

If you can build a web page, you already know most of what you need. This course teaches the rest: the manifest file that describes your extension, the pieces that run in different places, the messages that connect them, and how to publish the result to the Chrome Web Store. We use Manifest V3, the current extension platform.

An honest note about this course. Extensions can only run inside a browser that has loaded them from disk or from the store. A web page on this site cannot install one, and the chrome.* APIs do not exist in a normal page. So every runnable example here is a stand-in: plain JavaScript or HTML that imitates what the real API does, clearly labelled. The real extension code is shown in read-only blocks. In the next lessons you will also load a real extension in your own Chrome in about two minutes.

What an extension can do

Extensions use extension APIs, a set of JavaScript objects under chrome.*, together with permissions the user approves. With them an extension can:

  • Change web pages. A content script reads or edits the DOM of pages that match a URL pattern: hide elements, add buttons, translate text.
  • Add browser UI. A toolbar button with a popup, a side panel, context-menu entries, a badge on the icon, keyboard shortcuts, a custom new-tab page.
  • React to browser events. A tab was opened, a download finished, a bookmark was added, the user went idle.
  • Store data. Settings and small data sets that persist and can sync across the user's devices.
  • Block or redirect network requests with declarative rules.
  • Talk to servers with fetch, subject to permissions.
flowchart LR
    U["User"] --> T["Toolbar icon / popup"]
    U --> W["Web page"]
    W --> C["Content script"]
    T --> B["Service worker"]
    C --> B
    B --> A["chrome.* APIs<br/>tabs, storage, alarms"]

The extension is a small team of parts, each running in its own place.

What an extension cannot do

Extensions are powerful but fenced in:

  • They only get the capabilities listed under permissions and host_permissions in the manifest, and the Chrome Web Store reviews those requests.
  • They cannot run remotely hosted code. In Manifest V3 all JavaScript must ship inside the package.
  • They cannot read other extensions' data or the user's files, unless the user explicitly picks a file.
  • Pages (including chrome:// pages and the Web Store) are mostly off limits to content scripts.

These limits are why users can trust extensions at all, and why a later chapter on permissions and security matters.

Which browsers run them?

Chrome extensions use the WebExtensions-style model, which means most of the same code also runs in Microsoft Edge, Brave, Opera, Vivaldi and other Chromium browsers, usually without changes. Firefox and Safari use a very similar API (mostly the browser.* namespace) with small differences, so a well-written extension can often be ported. This course targets Chrome and mentions differences when they matter.

A first stand-in: what a content script does

The real power is touching a page you did not write. This stand-in shows the idea with a fake "page" and a function that plays the role of a content script.

A pretend content script

In a real extension that function would live in a file listed under content_scripts in the manifest, and Chrome would inject it into every page that matches your pattern.

Types of extension, by purpose

Almost every extension falls into a few families. Knowing them helps you choose parts when you design your own.

JS Choose the parts you need

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Extensions versus apps, bookmarklets and userscripts

  • A bookmarklet is a single JavaScript URL you click. It has no permissions system, no background work and no UI beyond what it draws on the page.
  • A userscript (via a manager) is closer, but depends on another extension to run it.
  • A web app lives on its own origin and cannot touch other sites.
  • A Chrome extension gets its own origin (chrome-extension://<id>), its own storage and a reviewed permission list.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. Which part of an extension edits the DOM of a web page the user is visiting?

    Content scripts are injected into matching pages and can read and change their DOM. The service worker has no DOM at all.
  2. 2. Why can the examples in this course not call chrome.* APIs directly in a lesson page?

    The chrome.* APIs are provided to extension contexts. Ordinary web pages do not get them, so we use labelled stand-ins.
  3. 3. Which statement about Manifest V3 is true?

    Remotely hosted code is not allowed in Manifest V3. Fetching data is fine; executing downloaded code is not.

Summary

  • A Chrome extension is HTML, CSS and JavaScript that extends the browser, installed per user.
  • It can change pages, add browser UI, react to events, store data and filter requests, but only within approved permissions.
  • Manifest V3 requires all code to ship in the package.
  • Most Chromium browsers run the same extensions; Firefox and Safari are close cousins.
  • Here, runnable examples are stand-ins; real extension code is read-only.

Next: The Anatomy of an Extension