Skip to content

Instantly share code, notes, and snippets.

@duplaja
Created September 9, 2019 23:36
Show Gist options
  • Save duplaja/53ce02e1d8f2ca88e522ab10efac2871 to your computer and use it in GitHub Desktop.
Save duplaja/53ce02e1d8f2ca88e522ab10efac2871 to your computer and use it in GitHub Desktop.
Allmusic.com Follow Artist Accessibility Fix (Tampermonkey Userscript)
// ==UserScript==
// @name Make Allmusic Accessible: Follow Artist
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Makes the clickable div button to follow an artist accessible to screenreaders
// @author Dan Dulaney
// @match https://www.allmusic.com/artist/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var followbutton = document.getElementsByClassName("artist-follow")[0];
followbutton.setAttribute("role", "button");
followbutton.setAttribute("tabindex",0);
followbutton.setAttribute("aria-label", "Follow Button");
doesfollowexist();
followbutton.addEventListener("click", doesfollowexist, false);
})();
function doesfollowexist() {
var followbutton = document.getElementsByClassName("artist-follow")[0];
var activefollow = document.getElementsByClassName('artist-follow following');
if (activefollow.length > 0) {
followbutton.setAttribute("aria-pressed","true");
} else {
followbutton.setAttribute("aria-pressed","false");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment