Infinite Scroll Spotify Episodes

Automatically clicks the "Load More Episodes" button when visible on Spotify

目前为 2024-10-04 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Infinite Scroll Spotify Episodes
  3. // @namespace https://greasyfork.org/en/users/1200587-trilla-g
  4. // @version 4.0
  5. // @description Automatically clicks the "Load More Episodes" button when visible on Spotify
  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. // Function to check if an element is in the viewport
  19. function isInViewport(element) {
  20. const rect = element.getBoundingClientRect();
  21. return (
  22. rect.top >= 0 &&
  23. rect.left >= 0 &&
  24. rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
  25. rect.right <= (window.innerWidth || document.documentElement.clientWidth)
  26. );
  27. }
  28.  
  29. // Function to check for the button and click it if it's in the viewport
  30. function checkForButtonAndClick() {
  31. const button = document.querySelector(buttonSelector);
  32. if (button && isInViewport(button)) {
  33. button.click();
  34. }
  35. }
  36.  
  37. // Run checkForButtonAndClick every second
  38. setInterval(checkForButtonAndClick, 1000);
  39.  
  40. })();