Kick.com - Auto select best quality

Auto select best quality

目前為 2023-12-15 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Kick.com - Auto select best quality
  3. // @namespace https://greasyfork.org/en/users/1200587-trilla-g
  4. // @version 1.0
  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 GM_addStyle
  10. // @run-at document-start
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Function to check if a quality option is selected and click it if not
  18. let checkQuality = (quality) => {
  19. let node = document.evaluate("//span[text()='"+quality+"']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  20. if (node){
  21. if (node.parentNode.getAttribute('aria-checked') === 'true'){
  22. return true;
  23. }
  24. node.parentNode.click();
  25. return true;
  26. }
  27. return false;
  28. };
  29.  
  30. // Function to set the stream quality
  31. let setStreamQuality = () => {
  32. if (checkQuality('1080p60') ||
  33. checkQuality('1080p') ||
  34. checkQuality('936p60') ||
  35. checkQuality('720p60') ||
  36. checkQuality('720p') ||
  37. checkQuality('Auto') ){
  38. return true;
  39. }
  40. return false;
  41. };
  42.  
  43. // Run the setStreamQuality function every 500 ms
  44. setInterval(() => {
  45. setStreamQuality();
  46. }, 500);
  47.  
  48. })();