Skip to content

Commit 8e5dcf5

Browse files
committed
Slack: Report incoming messages automatically (using a live region).
1 parent 7524c3c commit 8e5dcf5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

SlackA11yFixes.user.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,27 @@ function setStarred(elem) {
3333
elem.classList.contains("starred") ? "true" : "false");
3434
}
3535

36+
function message(text) {
37+
var live = document.getElementById("aria_live_announcer");
38+
live.textContent = text;
39+
}
40+
3641
function onNodeAdded(target) {
3742
if (target.matches(".offscreen[contenteditable]")) {
3843
// Hidden contentEditable near the bottom which doesn't seem to be relevant to the user.
3944
target.setAttribute("role", "presentation");
4045
return;
4146
}
47+
// Report incoming messages.
48+
if (target.matches("#msgs_div .message") && !target.classList.contains("unprocessed")) {
49+
// Just shove text into a live region that's already used for stuff like this.
50+
// It'd better/less hacky if the messages area itself were a live region,
51+
// but doing this results in double/triple speaking for some reason.
52+
// We also don't want the time reported in this case.
53+
sender = target.querySelector(".message_sender").textContent;
54+
body = target.querySelector(".message_body").textContent;
55+
message(sender + " " + body);
56+
}
4257
var elem;
4358
for (elem of target.querySelectorAll(".copy_only")) {
4459
// This includes text such as the brackets around message times.

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ It does the following:
6969
- Makes star controls (and their statuses) accessible.
7070
- Makes the close link for the about channel pane accessible.
7171
- Makes day separators in the message history and the about channel pane heading accessible as headings.
72+
- Reports incoming messages automatically (using a live region).
7273
- Hides an editable area which isn't shown visually.

0 commit comments

Comments
 (0)