Chrome Extensions and Chrome Apps Samples

repository·main·Indexed 12 days ago

https://github.com/googlechrome/chrome-extensions-samples

Official samples for Chrome Extensions and the deprecated Chrome Apps platform. This collection provides implementation patterns for various Chrome APIs, including hardware access (USB, Bluetooth, HID), system integration (fileSystem, storage, identity), network communication (messaging, sockets), and UI features (framelessWindows, webview). It also includes a CSP-compliant version of the Google API javascript client (gapi) for Chrome Packaged Apps.

Tokens
112.1K
Snippets
271
Records
559
Agent score
97%

What's inside Chrome Extensions Samples

  1. Overview of the Telnet sample

    main

    The Telnet sample is a Chrome extension that demonstrates how to use the Sockets API to act as a TCP client. It connects to aardmud.org on port 4000 and features an ANSI color renderer to display terminal output with color support.

    Key capabilities demonstrated:

    • Implementing a TCP client.
    • Rendering ANSI color sequences in a web context.
    • DNS resolution (noted as deprecated).
  2. Overview of the Text Replacer extension

    main

    The Text Replacer extension demonstrates how to replace text on a web page in response to different user triggers. Users can configure up to 5 pairs of text replacements via the extension's popup.

    Replacements are triggered in three ways:

    1. Clicking the Replace button in the extension popup.
    2. Selecting the Replace text option from the browser's context menu.
    3. Using the extension's defined keyboard shortcut (command).
  3. Overview of Alt Texter extension

    main

    Alt Texter is a Chrome extension sample that demonstrates how to generate accessible image descriptions using on-device AI. It leverages two specific Chrome AI APIs:

    • Prompt API: Uses Gemini Nano with multimodal input to analyze images and generate descriptions based on an 'object-action-context' framework.
    • Translator API: Enables translating the generated descriptions into multiple languages.

    When a user selects 'Generate alt text' from an image's context menu, the extension analyzes the image, generates a functional description, and provides options to translate or copy the text to the clipboard.

  4. Overview of the Code Editor sample

    main
    The Code Editor sample is a non-trivial Chrome extension demonstration that implements basic code editor features, including language detection and syntax highlighting. It demonstrates the use of the extended FileSystem API, which enables users to select files directly from their local disk for reading and writing operations. This sample is conceptually similar to the mini-code-edit sample found in the Chrome App samples repository.
  5. Overview of the Weather sample extension

    main

    The Weather sample is a basic 5-day weather forecast extension. It demonstrates how to use geolocation to automatically retrieve weather conditions for the user's current location. It also provides functionality for users to manually add cities and toggle between different temperature formats.

    Key technical features demonstrated:

    • Geolocation: Locating the user to fetch local weather.
    • Chrome Storage API: Persisting user preferences such as chosen cities and temperature settings.
    • Dynamic UI: Updating forecasts based on user input and location.