Hide the next video button that is not a playlist

https://www.reddit.com/r/userscripts/comments/1ik0gx2/how_to_hide_youtube_suggestedrecommended_video/

  1. // ==UserScript==
  2. // @name Hide the next video button that is not a playlist
  3. // @namespace https://greatest.deepsurf.us/users/821661
  4. // @match https://www.youtube.com/*
  5. // @grant none
  6. // @version 1.0
  7. // @author hdyzen
  8. // @description https://www.reddit.com/r/userscripts/comments/1ik0gx2/how_to_hide_youtube_suggestedrecommended_video/
  9. // ==/UserScript==
  10.  
  11. document.addEventListener("yt-renderidom-finished", () => {
  12. const isPlaylist = document.querySelector("ytd-watch-flexy[playlist]");
  13.  
  14. if (isPlaylist) {
  15. document.querySelector(".ytp-next-button")?.removeAttribute("hidden");
  16. } else {
  17. document.querySelector(".ytp-next-button")?.setAttribute("hidden", "");
  18. }
  19. });