Skip to content

Commit 2b9a3c5

Browse files
authored
Make PR filenames headings and label the file contents (#29)
- Makes the filenames in diff viewers level 2 headings. - Moves the filename first, rather than after a bunch of controls for that file. - Makes the file contents a region labelled by the filename. Useful when navigating by table rather than by heading.
1 parent a8af92d commit 2b9a3c5

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

GitHubA11yFixes.user.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// @name GitHub Accessibility Fixes
33
// @namespace http://axSgrease.nvaccess.org/
44
// @description Improves the accessibility of GitHub.
5-
// @author James Teh <jteh@mozilla.com>
6-
// @copyright 2019-2025 Mozilla Corporation, Derek Riemer
5+
// @author James Teh <jteh@mozilla.com>, Sascha Cowley <sascha@nvaccess.org>
6+
// @copyright 2019-2025 Mozilla Corporation, Derek Riemer, Sascha Cowley
77
// @license Mozilla Public License version 2.0
8-
// @version 2025.1
8+
// @version 2025.2
99
// @include https://github.com/*
1010
// ==/UserScript==
1111

@@ -168,6 +168,27 @@ const DYNAMIC_TWEAKS = [
168168
// Remove headings from folder and file lists.
169169
{selector: 'table[aria-labelledby=folders-and-files] :is(h2, h3)',
170170
tweak: makePresentational},
171+
// Make file viewer filenames headings, and the first item in the file viewer.
172+
{selector: '.file-header .file-info .Truncate:has(.Link--primary)',
173+
tweak: el => {
174+
makeHeading(el, 2);
175+
const headerRow = el.parentElement;
176+
const children = Array.from(headerRow.children);
177+
// Filename is the last child of .file-info, make it the first
178+
children.unshift(children.pop());
179+
if (headerRow) {
180+
makeElementOwn(headerRow, children);
181+
}
182+
}},
183+
// Label diffs and the like with their filename.
184+
{selector: '.file',
185+
tweak: el => {
186+
const label = el.querySelector(".Link--primary");
187+
const file = el.querySelector(".js-file-content");
188+
if (label && file) {
189+
makeRegion(file, label.textContent);
190+
}
191+
}},
171192
];
172193

173194
/*** Lights, camera, action! ***/

0 commit comments

Comments
 (0)