From 011d25219150b20880fec7a4dab0fbc432febe24 Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:10:05 +1000 Subject: [PATCH 1/2] Update GitHubA11yFixes.user.js --- GitHubA11yFixes.user.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/GitHubA11yFixes.user.js b/GitHubA11yFixes.user.js index 4775409..b2b124f 100644 --- a/GitHubA11yFixes.user.js +++ b/GitHubA11yFixes.user.js @@ -2,10 +2,10 @@ // @name GitHub Accessibility Fixes // @namespace http://axSgrease.nvaccess.org/ // @description Improves the accessibility of GitHub. -// @author James Teh -// @copyright 2019-2024 Mozilla Corporation, Derek Riemer +// @author James Teh , Sascha Cowley +// @copyright 2019-2024 Mozilla Corporation, Derek Riemer, Sascha Cowley // @license Mozilla Public License version 2.0 -// @version 2024.2 +// @version 2024.3 // @include https://github.com/* // ==/UserScript== @@ -163,6 +163,27 @@ const DYNAMIC_TWEAKS = [ // Remove headings from folder and file lists. {selector: 'table[aria-labelledby=folders-and-files] :is(h2, h3)', tweak: makePresentational}, + // Make file viewer filenames headings, and the first item in the file viewer. + {selector: '.file-header .file-info .Truncate:has(.Link--primary)', + tweak: el => { + makeHeading(el, 2) + let headerRow = el.parentElement + let children = Array.from(headerRow.children) + // Filename is the last child of .file-info, make it the first + children.unshift(children.pop()) + if (headerRow) { + makeElementOwn(headerRow, children); + } + }}, + // Label diffs and the like with their filename. + {selector: '.file', + tweak: el => { + label = el.querySelector(".Link--primary") + file = el.querySelector(".js-file-content") + if (label && file) { + makeRegion(file, label.textContent) + } + }}, ]; /*** Lights, camera, action! ***/ From 9892a93668ccf8c2ca41f0f5e422040ce42cb27f Mon Sep 17 00:00:00 2001 From: James Teh Date: Sat, 9 Aug 2025 20:33:58 +1000 Subject: [PATCH 2/2] Code review nits: missing semi-colons, missing variable declarations. --- GitHubA11yFixes.user.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/GitHubA11yFixes.user.js b/GitHubA11yFixes.user.js index c295790..f7a3fef 100644 --- a/GitHubA11yFixes.user.js +++ b/GitHubA11yFixes.user.js @@ -171,11 +171,11 @@ const DYNAMIC_TWEAKS = [ // Make file viewer filenames headings, and the first item in the file viewer. {selector: '.file-header .file-info .Truncate:has(.Link--primary)', tweak: el => { - makeHeading(el, 2) - let headerRow = el.parentElement - let children = Array.from(headerRow.children) + makeHeading(el, 2); + const headerRow = el.parentElement; + const children = Array.from(headerRow.children); // Filename is the last child of .file-info, make it the first - children.unshift(children.pop()) + children.unshift(children.pop()); if (headerRow) { makeElementOwn(headerRow, children); } @@ -183,10 +183,10 @@ const DYNAMIC_TWEAKS = [ // Label diffs and the like with their filename. {selector: '.file', tweak: el => { - label = el.querySelector(".Link--primary") - file = el.querySelector(".js-file-content") + const label = el.querySelector(".Link--primary"); + const file = el.querySelector(".js-file-content"); if (label && file) { - makeRegion(file, label.textContent) + makeRegion(file, label.textContent); } }}, ];