Samplefocus Downloader

Replaces the original download button to a one that redirects to the mp3 file page.

目前为 2025-01-25 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Samplefocus Downloader
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Replaces the original download button to a one that redirects to the mp3 file page.
  6. // @author ToxicBiohazard
  7. // @match *://*.samplefocus.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const originalLink = document.querySelector('.download-link');
  16.  
  17. if (!originalLink) {
  18. console.warn('Original download link not found.');
  19. return;
  20. }
  21.  
  22. const audioElement = document.querySelector('audio');
  23.  
  24. if (!audioElement || !audioElement.src) {
  25. console.error('No audio element found or no source loaded.');
  26. return;
  27. }
  28.  
  29. const audioSrc = audioElement.src;
  30.  
  31. const downloadSample = () => {
  32. if (confirm('Download the audio sample?')) {
  33. const link = document.createElement('a');
  34. link.href = audioSrc;
  35. link.download = 'extracted-audio.mp3';
  36. document.body.appendChild(link);
  37. link.click();
  38. document.body.removeChild(link);
  39. }
  40. };
  41.  
  42. const downloadButton = document.createElement('button');
  43. downloadButton.classList.add('btn-large', 'waves-effect', 'waves-light');
  44. downloadButton.textContent = 'Download Sample';
  45. downloadButton.addEventListener('click', downloadSample);
  46.  
  47. originalLink.parentNode.replaceChild(downloadButton, originalLink);
  48. })();