Automatic Jango Downloader

Automatically download all songs played in jango.com while listening.

当前为 2024-01-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Automatic Jango Downloader
  3. // @author Finomosec
  4. // @namespace http://meinebasis.de/
  5. // @description Automatically download all songs played in jango.com while listening.
  6. // @version 1.2
  7. // @grant GM.xmlHttpRequest
  8. // @match https://www.jango.com/*
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. const storagePrefix = "D:";
  13.  
  14. var originalAudio = window.Audio;
  15. unsafeWindow.Audio = exportFunction(function() {
  16. var audioElement = new originalAudio();
  17. audioElement.addEventListener('loadeddata', function() {
  18. var url = audioElement.src;
  19. if (url.indexOf(".jango.com/") == -1) {
  20. return;
  21. }
  22.  
  23. var fileName = url.substring(url.lastIndexOf("/") + 1);
  24. var fileSuffix = url.substring(url.lastIndexOf("."));
  25. var niceFileName = unsafeWindow.document.title.replace(": ", " - ").replace(" - Jango", "") + fileSuffix;
  26.  
  27. if (localStorage.getItem(storagePrefix + fileName)) {
  28. // console.info('Already downloaded:', niceFileName);
  29. return;
  30. }
  31.  
  32. // console.info('Downloading:', niceFileName);
  33. GM.xmlHttpRequest({
  34. method: "GET",
  35. url: url,
  36. onload: function(response) {
  37. var blob = new Blob([response.response], {type: "audio/mpeg"});
  38. var url = URL.createObjectURL(blob);
  39. var link = document.createElement('a');
  40. link.href = url;
  41. link.download = niceFileName;
  42. link.click();
  43. localStorage.setItem(storagePrefix + fileName, "1");
  44. }
  45. });
  46. });
  47. return audioElement;
  48. }, unsafeWindow);