User:Vitrinekast/Snatch these snippets
< User:Vitrinekast
Revision as of 11:30, 9 October 2023 by Vitrinekast (talk | contribs)
Copy-paste this into your console! (Right click -> inspect elements > console)
Adding audio elements to index files
// select all links
document.querySelectorAll("a").forEach((link) => {
// if it includes your audio format (regex)
if(link.href.match(/\.(?:wav|mp3)$/i)) {
// create an audio element and set its source to yourlink
var audioEl = document.createElement("audio");
audioEl.src = link.href;
audioEl.controls = true;
audioEl.style.display = "block";
link.insertAdjacentElement("afterend", audioEl)
};
});