soundcloud scroll queue

Adds a button that automatically scrolls the queue until disabled

ของเมื่อวันที่ 06-10-2019 ดู เวอร์ชันล่าสุด

  1. // ==UserScript==
  2. // @name soundcloud scroll queue
  3. // @version 1.0
  4. // @description Adds a button that automatically scrolls the queue until disabled
  5. // @author bhackel
  6. // @match https://soundcloud.com/*
  7. // @grant none
  8. // @run-at document-start
  9. // @noframes
  10. // @namespace https://greasyfork.org/en/users/324178-bhackel
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function setup() {
  17. var btn = document.createElement("Button");
  18. btn.className = "bhackelSCScroll sc-button sc-button-medium";
  19. btn.innerHTML = "Scroll Down";
  20. btn.onclick = function(){ start(this); };
  21.  
  22. var queue_panel = document.getElementsByClassName("queue__panel")[0];
  23. if (queue_panel) {
  24. queue_panel.insertBefore(btn, queue_panel.children[1]);
  25. } else {
  26. setTimeout(setup, 1000);
  27. }
  28. }
  29.  
  30. function start(d){
  31. if (d.interval){
  32. clearInterval(d.interval);
  33. d.interval = 0;
  34. d.innerHTML='Scroll Down';
  35. } else {
  36. d.interval=setInterval(function(){
  37. scroll();
  38. },1000);
  39. d.innerHTML='Stop Scrolling';
  40. }
  41. }
  42.  
  43. function scroll() {
  44. var scrollableQueue = document.getElementsByClassName("queue__scrollableInner g-scrollable-inner").item(0);
  45. var queueContainer = document.getElementsByClassName("queue__itemsHeight").item(0);
  46. var scrollToHeight = parseInt(queueContainer.style.height);
  47. scrollableQueue.scroll(0,scrollToHeight);
  48. }
  49.  
  50. setup();
  51.  
  52. })();