Skip to content

Instantly share code, notes, and snippets.

@johnrees
Created November 29, 2019 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnrees/65217999c9e27b03bd517666d7055b6d to your computer and use it in GitHub Desktop.
Save johnrees/65217999c9e27b03bd517666d7055b6d to your computer and use it in GitHub Desktop.
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