Skip to content

Instantly share code, notes, and snippets.

@johnrees

johnrees/a11y.js

Created Nov 29, 2019
Embed
What would you like to do?
js to make cargocollective a bit more accessibility friendly
try {
// add img alt tags using filename
document.addEventListener(
"DOMContentLoaded",
function() {
[...document.getElementsByTagName("img")].forEach(i => {
i.alt = i.src
.split("/")
.pop()
.split(".")
.slice(0, -1)
.join("");
});
},
false
);
// replace meta tag
[...document.getElementsByTagName("meta")].forEach(m => {
if (m.name === "viewport") {
m.content = "initial-scale=1.0, maximum-scale=5.0, user-scalable=yes";
}
});
} catch (e) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment