Skip to content

Commit 7e537e7

Browse files
committed
WhatsApp: Remove phone numbers from the labels of messages from unknown contacts.
1 parent 7bc0551 commit 7e537e7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

WhatsAppA11yFixes.user.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// @namespace http://axSgrease.nvaccess.org/
44
// @description Improves the accessibility of WhatsApp Web.
55
// @author James Teh <jamie@jantrid.net>
6-
// @copyright 2019-2025 Mozilla Corporation, Derek Riemer, James Teh
6+
// @copyright 2019-2026 Mozilla Corporation, Derek Riemer, James Teh
77
// @license Mozilla Public License version 2.0
8-
// @version 2025.2
8+
// @version 2026.1
99
// @include https://web.whatsapp.com/
1010
// ==/UserScript==
1111

@@ -194,7 +194,7 @@ const LOAD_TWEAKS = [
194194

195195
// Attributes that should be watched for changes and cause dynamic tweaks to be
196196
// applied.
197-
const DYNAMIC_TWEAK_ATTRIBS = [];
197+
const DYNAMIC_TWEAK_ATTRIBS = ["aria-label"];
198198

199199
// Tweaks that must be applied whenever an element is added/changed.
200200
const DYNAMIC_TWEAKS = [
@@ -209,6 +209,17 @@ const DYNAMIC_TWEAKS = [
209209
}
210210
}
211211
},
212+
{selector: '.message-in[aria-label]',
213+
tweak: el => {
214+
// Remove phone numbers for unknown contacts. These have a slightly different
215+
// format for normal chats and group chats.
216+
const m = el.ariaLabel.match(
217+
/^(?:Maybe (.*? ))?\+\d{1,2} [\d ]+ (.*)$/s
218+
);
219+
if (m) {
220+
el.ariaLabel = `Maybe ${m[1] || ""} ${m[2]}`;
221+
}
222+
}},
212223
];
213224

214225
/** add your specific initialization here, so that if you ever update the framework from new skeleton your inits are not overridden. */

0 commit comments

Comments
 (0)