forked from jcsteh/axSGrease
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoogleCodeA11yFixes.user.js
More file actions
54 lines (47 loc) · 1.61 KB
/
GoogleCodeA11yFixes.user.js
File metadata and controls
54 lines (47 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// ==UserScript==
// @name Google Code Accessibility Fixes
// @namespace http://www.jantrid.net/axSGrease/
// @description Improves the accessibility of Google Code.
// @author James Teh <jamie@nvaccess.org>
// @copyright 2014 James Teh
// @license GNU General Public License version 2.0
// @version 2014.1
// @include https://code.google.com/p/*/issues/*
// ==/UserScript==
function fixStar(node) {
node.setAttribute("role", "checkbox");
node.setAttribute("aria-checked",
(node.src.indexOf("star_on.gif") == -1) ? "false" : "true");
}
function makeHeading(elem, level) {
elem.setAttribute("role", "heading");
elem.setAttribute("aria-level", level);
}
function makeHeadings() {
// Title.
var elem = document.querySelector("#issueheader span.h3");
makeHeading(elem, 1);
// Description and comments.
for (elem of document.getElementsByClassName("author"))
makeHeading(elem, 2);
// Make changes heading.
var elem = document.querySelector("#makechanges div.h4");
makeHeading(elem, 2);
}
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
try {
if (mutation.type === "attributes") {
if (mutation.attributeName == "src" && mutation.target.id == "star")
fixStar(mutation.target);
}
} catch (e) {
// Catch exceptions for individual mutations so other mutations are still handled.
GM_log("Exception while handling mutation: " + e);
}
});
});
observer.observe(document, {attributes: true,
subtree: true, attributeFilter: ["src"]});
fixStar(document.getElementById("star"));
makeHeadings();