Infinite Scroll Spotify Episodes

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

目前为 2024-07-08 提交的版本,查看 最新版本

  1. /// ==UserScript==
  2. // @name Infinite Scroll Spotify Episodes
  3. // @namespace https://greasyfork.org/en/users/1200587-trilla-g
  4. // @version 2.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 with the exact class name
  16. const buttonSelector = '.vqQmhCMZq7eUtTV7YYOQ.epDbBe.LegacyChipInner__ChipInnerComponent-sc-1qguixk-0';
  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. console.log('Button clicked!');
  35. }
  36. }
  37.  
  38. // Run checkForButtonAndClick every second
  39. setInterval(checkForButtonAndClick, 1000);
  40.  
  41. // Initial check in case the button is already present when the script runs
  42. checkForButtonAndClick();
  43. })();
  44.