User:Vitrinekast/Snatch these snippets

From XPUB & Lens-Based wiki
< User:Vitrinekast
Revision as of 12:27, 9 October 2023 by Vitrinekast (talk | contribs) (Created page with "Copy-paste this into your console! (Right click -> inspect elements > console) == Adding audio elements to index files == <syntaxhighlight lang="javascript"> // select all links document.querySelectorAll("a").forEach((link) => { // if it includes your audio format if(link.href.indexOf(".mp3") > 0) { // create an audio element and set its source to yourlink var audioEl = document.createElement("audio"); audioEl.src = link.href; au...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

    if(link.href.indexOf(".mp3") > 0) {
        // 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)
    };
});