Skip to content

Match comma-separated unread counts in tab titles - #1

Open
doug-proctor wants to merge 1 commit into
u00dxk2:masterfrom
doug-proctor:support-comma-separated-unread-counts
Open

Match comma-separated unread counts in tab titles#1
doug-proctor wants to merge 1 commit into
u00dxk2:masterfrom
doug-proctor:support-comma-separated-unread-counts

Conversation

@doug-proctor

Copy link
Copy Markdown

What changed

One line in content.js. The regex that strips the unread count from the tab title:

-const cleanedTitle = title.replace(/\s*\(\d+\)\s*/g, ' ')...
+const cleanedTitle = title.replace(/\s*\(\d[\d,]*\)\s*/g, ' ')...

The comment above it was updated to use Inbox (1,234) as the example.

Why

Gmail writes unread counts above 999 with a comma separator, for example Inbox (1,234). The old pattern \(\d+\) only matched runs of digits, so it did not match those titles. The count stayed visible in the tab for anyone with more than 999 unread messages — which is a large share of the people this extension is for.

The new pattern requires a leading digit, then allows digits and commas.

Test results

I ran the new regex against these titles:

Input Output
Inbox (1,234) Inbox
Gmail - Primary (5) Gmail - Primary
Inbox (1,234) - user@gmail.com - Gmail Inbox - user@gmail.com - Gmail
Inbox (12,345,678) Inbox

Plain counts like (5) still work, so this is not a regression.

Note for the reviewer

The pattern accepts a trailing comma, so Inbox (1,) becomes Inbox. It rejects a leading comma and an empty pair, so (,234) and () are left alone. Gmail does not produce (1,), so this does not affect real titles. Tightening it to \(\d{1,3}(,\d{3})*\) would be stricter but would then miss any format that is not exactly three-digit groups. I left it loose on purpose.

There are no automated tests in this repo, so the table above is manual verification with Node, not a test suite.

🤖 Generated with Claude Code

Gmail formats unread counts above 999 with commas, e.g. "Inbox (1,234)".
The old pattern \(\d+\) only matched digits, so those titles were left
unchanged and the count stayed visible.

The pattern is now \(\d[\d,]*\), which requires a leading digit and then
allows digits and commas. Plain counts like (5) still match.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant