Created
September 9, 2019 23:36
-
-
Save duplaja/53ce02e1d8f2ca88e522ab10efac2871 to your computer and use it in GitHub Desktop.
Allmusic.com Follow Artist Accessibility Fix (Tampermonkey Userscript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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