Kick.com - Auto select best quality

Auto select best quality

  1. // ==UserScript==
  2. // @name Kick.com - Auto select best quality
  3. // @namespace https://greasyfork.org/en/users/1200587-trilla-g
  4. // @version 1.1
  5. // @author Trilla_G
  6. // @description Auto select best quality
  7. // @match *://kick.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=kick.com
  9. // @grant none
  10. // @run-at document-idle
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Function to check if the quality option is selected and click it if not
  18. let checkQuality = () => {
  19. let qualityOption = document.querySelector("div.betterhover\\:hover\\:text-primary:nth-child(2)");
  20. if (qualityOption) {
  21. let isSelected = qualityOption.parentNode.getAttribute("aria-checked") === "true";
  22. if (!isSelected) {
  23. console.log("Selecting 1080p60 quality...");
  24. qualityOption.click();
  25. qualityOption.dispatchEvent(new Event('click', { bubbles: true }));
  26. }
  27. return true;
  28. }
  29. return false;
  30. };
  31.  
  32. // Wait for the quality menu to load, then apply the selection
  33. let setStreamQuality = () => {
  34. if (!checkQuality()) {
  35. console.log("Quality option not found yet, retrying...");
  36. }
  37. };
  38.  
  39. // Run the setStreamQuality function every 500ms
  40. let interval = setInterval(setStreamQuality, 500);
  41.  
  42. // Stop checking after 10 seconds to prevent unnecessary loops
  43. setTimeout(() => {
  44. clearInterval(interval);
  45. }, 10000);
  46. })();