Skip to content

Commit b7e6aef

Browse files
committed
GitHub: Ensure the branch name is included in the label for the branch selector buttons when comparing branches/creating pull requests.
1 parent 8dc3c90 commit b7e6aef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

GitHubA11yFixes.user.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var idCounter = 0;
4141

4242
function onNodeAdded(target) {
4343
var elem;
44-
var res = document.location.href.match(/github.com\/[^\/]+\/[^\/]+(?:\/([^\/]+))?(?:\/([^\/]+))?(?:\/([^\/]+))?(?:\/([^\/]+))?/);
44+
var res = document.location.href.match(/github.com\/[^\/]+\/[^\/]+(?:\/([^\/?]+))?(?:\/([^\/?]+))?(?:\/([^\/?]+))?(?:\/([^\/?]+))?/);
4545
// res[1] to res[4] are 4 path components of the URL after the project.
4646
// res[1] will be "issues", "pull", "commit", etc.
4747
// Empty path components will be undefined.
@@ -70,6 +70,11 @@ function onNodeAdded(target) {
7070
// Ensure the table never gets treated as a layout table.
7171
if (elem = target.querySelector(".files"))
7272
elem.setAttribute("role", "table");
73+
} else if (res[1] == "compare") {
74+
// Branch selector buttons.
75+
// These have an aria-label which masks the name of the branch, so kill it.
76+
for (elem of target.querySelectorAll("button.branch"))
77+
elem.removeAttribute("aria-label");
7378
}
7479
if (["pull", "commit"].indexOf(res[1]) >= 0 && res[2]) {
7580
// Pull request or commit.

0 commit comments

Comments
 (0)