User:Vitrinekast/Snatch these snippets

From XPUB & Lens-Based wiki

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)
    };
});