|
10 | 10 | // @include https://*.slack.com/* |
11 | 11 | // ==/UserScript== |
12 | 12 |
|
13 | | -function initial() { |
| 13 | +function makeHeading(elem, level) { |
| 14 | + elem.setAttribute("role", "heading"); |
| 15 | + elem.setAttribute("aria-level", level); |
| 16 | +} |
| 17 | + |
| 18 | + function initial() { |
14 | 19 | var elem; |
15 | 20 | // In DOM order, the footer is earlier than the messages. |
16 | 21 | // Put it below for a11y (as it appears visually). |
@@ -86,15 +91,13 @@ function onNodeAdded(target) { |
86 | 91 | elem.setAttribute("aria-label", "star"); |
87 | 92 | setStarred(elem); |
88 | 93 | } |
89 | | - // Make the current channel title a level 2 heading. |
90 | | - if (elem = target.querySelector("#channel_title")) { |
91 | | - elem.setAttribute("role", "heading"); |
92 | | - elem.setAttribute("aria-level", "2"); |
| 94 | + // Make the current channel/direct message title a level 2 heading. |
| 95 | + for (elem of target.querySelectorAll("#channel_title, #im_title")) { |
| 96 | + makeHeading(elem, 2); |
93 | 97 | } |
94 | 98 | // Make level3 headings for day separators in message history, individual search results, individual threads in All Threads. |
95 | 99 | for (elem of target.querySelectorAll(".day_divider, .search_result_header, .thread_header")) { |
96 | | - elem.setAttribute("role", "heading"); |
97 | | - elem.setAttribute("aria-level", "3"); |
| 100 | + makeHeading(elem, 3); |
98 | 101 | } |
99 | 102 | // Kill some extraneous white space. |
100 | 103 | for (elem of target.querySelectorAll(".message_gutter, .message_content > i.copy_only br")) { |
|
0 commit comments