Mixcloud Download

Adds a download button to the Mixcloud player.

  1. // ==UserScript==
  2. // @name Mixcloud Download
  3. // @namespace schwarztee
  4. // @description Adds a download button to the Mixcloud player.
  5. // @include https://www.mixcloud.com/*
  6. // @copyright 2016, schwarztee
  7. // @license MIT
  8. // @version 0.1.2-deactivated
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function(){
  13.  
  14. 'use strict'
  15. console.log( '[Mixcloud Download] Script deactivated. Needs update to support HTTP live streaming, sorry.' )
  16.  
  17. /*function makeButton( href )
  18. {
  19. let title = ''
  20.  
  21. try
  22. {
  23. // try to get audio title
  24. title = document.querySelector( '.player-cloudcast-title' ).textContent
  25. }
  26. catch ( exception ) {}
  27.  
  28. // strip any sensitive characters for use as filename
  29. title = title.replace( /[^A-Za-z0-9\-\.\+]/g, '_' )
  30.  
  31. // create anchor element
  32. let button = document.createElement( 'a' )
  33. button.className = 'player-follow-button dwnld'
  34. button.download = title && title+'.m4a' || ''
  35. button.style.display = 'inline'
  36. button.style.color = 'inherit'
  37. button.title = "Download"
  38. button.innerHTML = '↓'
  39. button.href = href
  40.  
  41. // add button to player
  42. document.querySelector( '.player-cloudcast-author' ).appendChild( button )
  43. }
  44.  
  45. function removeButton()
  46. {
  47. try
  48. {
  49. // try to find and remove existing download button
  50. document.querySelector( '.player-cloudcast-author a.dwnld' ).remove()
  51. }
  52. catch ( exception ) {}
  53. }
  54.  
  55. let oldURL = ''
  56.  
  57. function checkAudio()
  58. {
  59. let newURL = ''
  60.  
  61. try
  62. {
  63. // try to find audio and get current source URL
  64. newURL = document.querySelector( 'audio source' ).src
  65. }
  66. catch ( exception )
  67. {
  68. // developer information
  69. console.log( "[Mixcloud Download] No active audio element found." )
  70. }
  71.  
  72. // source URL found?
  73. if ( newURL )
  74. {
  75. // new URL or download button not present?
  76. if ( newURL != oldURL || !document.querySelector( '.player-cloudcast-author a.dwnld' ) )
  77. {
  78. // developer information
  79. console.log( "[Mixcloud Download] Found audio source:", newURL )
  80.  
  81. // remove any old button
  82. removeButton()
  83.  
  84. // make new button
  85. makeButton( newURL )
  86. }
  87. }
  88. else
  89. {
  90. // remove any old button
  91. removeButton()
  92. }
  93.  
  94. // update URL cache
  95. oldURL = newURL
  96. }
  97.  
  98. // check player every four seconds
  99. setInterval( checkAudio, 4000 )*/
  100.  
  101. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址