Infinite Scroll Spotify Episodes

Automatically clicks the "Load More Episodes" button when visible on Spotify using IntersectionObserver for improved efficiency

  1. // ==UserScript==
  2. // @name Infinite Scroll Spotify Episodes
  3. // @namespace https://greasyfork.org/en/users/1200587-trilla-g
  4. // @version 4.1
  5. // @description Automatically clicks the "Load More Episodes" button when visible on Spotify using IntersectionObserver for improved efficiency
  6. // @author Trilla_G
  7. // @match *://*.open.spotify.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Define the selector for the button
  16. const buttonSelector = '.vqQmhCMZq7eUtTV7YYOQ';
  17.  
  18. // Set up an observer to watch for the button entering the viewport
  19. const observer = new IntersectionObserver(entries => {
  20. entries.forEach(entry => {
  21. if (entry.isIntersecting) {
  22. entry.target.click();
  23. }
  24. });
  25. });
  26.  
  27. // Monitor the document for the button's appearance
  28. function observeButton() {
  29. const button = document.querySelector(buttonSelector);
  30. if (button) {
  31. observer.observe(button);
  32. }
  33. }
  34.  
  35. // Set up a MutationObserver to detect changes in the page and find the button
  36. const mutationObserver = new MutationObserver(observeButton);
  37. mutationObserver.observe(document.body, { childList: true, subtree: true });
  38.  
  39. // Initial button observation
  40. observeButton();
  41. })();