Chrome extension/AI/Working

ChatMeter

Estimates tokens, remaining context, and illustrative water and cost figures for the Claude or ChatGPT conversation you have open.

Built with
  • JavaScript
  • Manifest V3
  • Content script
  • DOM heuristics
Runs as
Floating widget (content script)
Status · v1.0.0
Plain JavaScript content script; it depends on each site's current markup, so it breaks if that changes.

§ 01

What it is

A small floating panel on claude.ai and chatgpt.com. One click estimates how many tokens the current conversation uses, split into what you wrote and what the model wrote, and how much of the context window is left. It can also total every conversation in the sidebar.

The problem

Chat apps do not show how big a conversation has become or how close it is to the context limit, and long chats quietly lose earlier details.

Runtime

  1. WidgetFloating panel
  2. Render passScroll to load old messages
  3. ScanRole-specific selectors
  4. EstimateEditable constants

§ 02

Screenshot

ChatMeter panel beside a chat, showing input, output and total token estimates, a context bar, and water and cost estimates
After Analyse This Chat, on a sample conversation.

Real screenshots of the extension's own interface; some show sample content.

§ 03

How it works

  1. 01

    Open a conversation and click the CM button, then "Analyse This Chat".

  2. 02

    Both sites only render the messages near the viewport, so ChatMeter scrolls the chat to the top and back to make earlier messages load before it counts.

  3. 03

    Your messages and the model's replies are found with separate selectors and counted separately; text that cannot be attributed is counted as unclassified.

  4. 04

    "Analyse All Chats" opens each conversation in the sidebar in turn through the site's own links, adds them up, and returns to where you started. Results can be copied as a text report.

§ 04

Architecture

  1. 01

    Content script

    One vanilla-JS script and stylesheet injected only on claude.ai, chatgpt.com and chat.openai.com. It makes no network requests.

  2. 02

    Site profiles

    Per-site selectors for user messages, assistant messages and chat links, plus a per-site context limit.

  3. 03

    Estimator

    Characters per token, context limits, water per token and cost per 1K tokens are constants you can edit in the widget's settings and are saved to chrome.storage.

§ 05

Key features

  • Input, output and total token estimates for the open chat.
  • A context bar against the site's approximate limit (200K for Claude, 128K for ChatGPT by default, editable).
  • Illustrative water and cost estimates, clearly labelled as rough.
  • Analyse every chat listed in the sidebar in one pass.
  • Copyable plain-text report.

§ 06

Technical implementation

Working around virtualized lists

Counting the DOM naively undercounts long chats because old messages are not rendered. Scrolling the message container before scanning makes most of them mount - a best-effort fix the code documents as such.

Honest about approximation

The source lists every heuristic and its limits, and the widget labels its numbers as estimates: about four characters per token, and placeholder water and price rates.

§ 07

Permissions & browser APIs

claude.ai, chatgpt.com, chat.openai.com
The only sites the widget is injected into.
storage
Saves the editable estimation settings.

§ 08

Hard parts & limits

  • The counts are estimates, not tokenizer output.
  • Selectors are tied to each site's current markup and need updating when the sites change.