Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [1.7.4] - 2026-05-18

### Fixed
- **Date stamp read aloud before message body** — the chat UI injects a date string (e.g. "May 18") into each message element's `innerText`. This appeared in the body after timestamp stripping, blocking the sender-name strip and causing spoken output like "Alice May 18 Alice Smith hello". Added `DATE_RE` (matches `Month Day` and `Month Day, Year` patterns) applied in both extractors and in `normalizeMsg`, so dates are removed before the sender strip runs and before the dedup key is computed.
- **Sender name announced twice** (`"Alice: Alice: hello everyone"`) — two separate fixes:
1. `stripSenderFromStart` now uses `\W*` after the sender name instead of a narrow character class (`[:·|>-]?`). This absorbs any separator (colon, dash, unicode punctuation, etc.) regardless of what the chat UI inserts.
2. Both extractors and `normalizeMsg` now explicitly try a first-name-only strip after the full-name strip. VTF formats the message body as `"FirstName: message"` even when the sender element contains the full name, so stripping just `"Alice Smith"` leaves `"Alice: hello"` in the body. The additional first-name pass removes it.
- **Date stamp read aloud before message body** — the chat UI injects a date string (e.g. "May 18") into each message element's `innerText`. This appeared in the body after timestamp stripping, blocking the sender-name strip and causing spoken output like `"Alice May 18 Alice Smith hello"`. Added `DATE_RE` (matches `Month Day` and `Month Day, Year` patterns) applied in both extractors and in `normalizeMsg`, so dates are removed before the sender strip runs and before the dedup key is computed.

---

Expand Down
16 changes: 15 additions & 1 deletion message-reader.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@

function stripSenderFromStart(body, sender) {
if (!sender) return body;
const re = new RegExp('^' + escapeRegex(sender) + '\\s*[:·|>-]?\\s*', 'i');
// \W* after the name absorbs any separator (colon, dash, space, etc.)
// without restricting to a narrow character class.
const re = new RegExp('^' + escapeRegex(sender) + '\\W*', 'i');
let prev;
do { prev = body; body = body.replace(re, '').trim(); } while (body !== prev);
return body;
Expand Down Expand Up @@ -269,6 +271,10 @@
if (!body) return null;

body = stripSenderFromStart(body, sender);
// Also strip first-name only — VTF can format the body as "FirstName: message"
// even when the sender element contains the full name.
const senderFirst = sender.split(/\s+/)[0];
if (senderFirst !== sender) body = stripSenderFromStart(body, senderFirst);

// Strip leading badge words.
let words = body.split(/\s+/);
Expand Down Expand Up @@ -326,6 +332,8 @@
if (!body) return null;

body = stripSenderFromStart(body, sender);
const senderFirst = sender.split(/\s+/)[0];
if (senderFirst !== sender) body = stripSenderFromStart(body, senderFirst);

if (!sender) {
const m = body.match(/^\s*([^:\n]{1,60}):\s*(.+)/s);
Expand Down Expand Up @@ -407,6 +415,12 @@
msg.body = msg.body.replace(DATE_RE, ' ').replace(/\s+/g, ' ').trim();
msg.body = stripSenderFromStart(msg.body, msg.fullSender);
msg.body = stripSenderFromStart(msg.body, msg.sender);
// Extra pass with just the first name of fullSender — covers the case where
// VTF formats the body as "FirstName: message" even when fullSender is a full name.
const firstName = (msg.fullSender || '').split(/\s+/)[0];
if (firstName && firstName !== msg.fullSender && firstName !== msg.sender) {
msg.body = stripSenderFromStart(msg.body, firstName);
}
msg.body = msg.body.replace(TS_LEADING, '').trim();
return msg.body ? msg : null;
}
Expand Down