Skip to content

Commit a0fdb18

Browse files
committed
Slack: Make messages accessible as list items. Enables screen reader users to navigate between them using list item quick nav.
1 parent 180e423 commit a0fdb18

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

SlackA11yFixes.user.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function onNodeAdded(target) {
4444
target.setAttribute("role", "presentation");
4545
return;
4646
}
47-
// Report incoming messages.
47+
// Report incoming messages and make them list items.
4848
if (target.matches("#msgs_div .message") && !target.classList.contains("unprocessed")) {
4949
// Just shove text into a live region that's already used for stuff like this.
5050
// It'd better/less hacky if the messages area itself were a live region,
@@ -53,8 +53,12 @@ function onNodeAdded(target) {
5353
sender = target.querySelector(".message_sender").textContent;
5454
body = target.querySelector(".message_body").textContent;
5555
message(sender + " " + body);
56+
target.setAttribute("role", "listitem");
5657
}
5758
var elem;
59+
// Make existing messages lit items.
60+
for (elem of target.querySelectorAll("#msgs_div .message"))
61+
elem.setAttribute("role", "listitem");
5862
for (elem of target.querySelectorAll(".copy_only")) {
5963
// This includes text such as the brackets around message times.
6064
// These chunks of text are block elements, even though they're on the same line.

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ This script improves the accessibility of [Slack](https://www.slack.com/).
6565
It does the following:
6666

6767
- Reorders some elements which appear in the wrong place for accessibility. For example, using this script, the input area appears near the bottom of the page as it does visually instead of at the top.
68+
- Makes messages accessible as list items.
6869
- Makes message timestamps appear on a single line instead of crossing several lines.
6970
- Makes star controls (and their statuses) accessible.
7071
- Makes the close link for the about channel pane accessible.

0 commit comments

Comments
 (0)