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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ 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.

---

## [1.7.3] - 2026-05-18

### Added
Expand Down Expand Up @@ -152,6 +159,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

---

[1.7.4]: https://github.com/sbcmsbgithub/message-reader/releases/tag/v1.7.4
[1.7.3]: https://github.com/sbcmsbgithub/message-reader/releases/tag/v1.7.3
[1.7.2]: https://github.com/sbcmsbgithub/message-reader/releases/tag/v1.7.2
[1.7.1]: https://github.com/sbcmsbgithub/message-reader/releases/tag/v1.7.1
Expand Down
8 changes: 7 additions & 1 deletion message-reader.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Message Reader
// @namespace https://github.com/sbcmsbgithub/message-reader
// @version 1.7.3
// @version 1.7.4
// @description Reads chat messages aloud on configured sites. Pick any element as the watched container. Includes playback controls, ignore list, voice/rate/volume settings, and time/first-name options.
// @match *://*/*
// @grant none
Expand Down Expand Up @@ -217,6 +217,9 @@
const TS_LEADING = /^\[?\d{1,2}:\d{2}(?::\d{2})?\s*(?:AM|PM)?\]?\s*/i;
// Matches http/https URLs and bare www. links — replaced with "URL posted" before speaking.
const URL_RE = /https?:\/\/\S+|www\.\S+/gi;
// Matches date stamps like "May 18" or "May 18, 2026" injected by the chat UI into
// the element's innerText — stripped from the body before speaking.
const DATE_RE = /\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s+\d{1,2}(?:,?\s*\d{4})?\b/gi;

function getMessageRoot(node) {
if (!(node instanceof HTMLElement)) return null;
Expand Down Expand Up @@ -258,6 +261,7 @@

let body = raw.replace(TS_BRACKET, ' ')
.replace(TS_BARE, ' ')
.replace(DATE_RE, ' ')
.replace(/\s+/g, ' ')
.trim();
// Safety-net: strip any leading bare time that TS_BARE missed (no AM/PM suffix).
Expand Down Expand Up @@ -316,6 +320,7 @@
if (tsMatch && tsMatch.length) timeText = tsMatch[0].replace(/[\[\]]/g, '').trim();

let body = raw.replace(TS_BRACKET, ' ').replace(TS_BARE, ' ')
.replace(DATE_RE, ' ')
.replace(/\s+/g, ' ').trim();
body = body.replace(TS_LEADING, '').trim();
if (!body) return null;
Expand Down Expand Up @@ -399,6 +404,7 @@
// during live handling — so the keys always match.
function normalizeMsg(msg) {
if (!msg || !msg.body) return null;
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);
msg.body = msg.body.replace(TS_LEADING, '').trim();
Expand Down