Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ongnxco/9a983db566a1e22eadc90655361d2a90 to your computer and use it in GitHub Desktop.
Save ongnxco/9a983db566a1e22eadc90655361d2a90 to your computer and use it in GitHub Desktop.
Bookmarklet to download mp3 files on ldoceonline
javascript:(function() {
  // Find all spans with the data-src-mp3 attribute
  const spans = document.querySelectorAll('span[data-src-mp3]');

  // Create an array of .mp3 file URLs
  const mp3Urls = Array.from(spans).map(span => span.getAttribute('data-src-mp3'));

  // Iterate through the array of URLs and download each file
  mp3Urls.forEach(url => {
    const anchor = document.createElement('a');
    anchor.href = url;
    anchor.download = url.split('/').pop();
    anchor.click();
  });

  // Display a notification
  alert('Downloaded ' + mp3Urls.length + ' .mp3 files!');
})();

How to use:

Copy the JavaScript code above.

Open your web browser.

Go to the web page that contains the .mp3 files you want to download.

Open the Bookmarks tab.

Right-click on an empty area and select "Add Bookmark".

Name the bookmark "Download all .mp3 files".

Paste the JavaScript code into the URL field.

Save the bookmark.

Click the "Download all .mp3 files" bookmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment