Greasy Fork is available in English.

Chzzk Auto High Quality

Chzzk자동으로 최고화질로 설정

  1. // ==UserScript==
  2. // @name Chzzk Auto High Quality
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.2
  5. // @description Chzzk자동으로 최고화질로 설정
  6. // @author DSK
  7. // @match https://chzzk.naver.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11. (function() {
  12. 'use strict';
  13.  
  14. let lastUrl = location.href;
  15. let adBlockInterval = null;
  16. let qualityInterval = null;
  17. let playbackInterval = null;
  18.  
  19. function handleAdBlockPopup() {
  20. const popupContainer = document.querySelector('div[class^="popup_container"]');
  21. if (popupContainer && popupContainer.textContent.includes('광고 차단 프로그램을 사용 중이신가요')) {
  22. popupContainer.remove();
  23.  
  24. // Remove existing keydown event listener first
  25. const existingListener = (event) => {
  26. if (!(event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA' || event.target.tagName === 'PRE')) {
  27. let button;
  28. switch (event.key) {
  29. case 'k':
  30. case ' ':
  31. button = document.querySelector('button.pzp-playback-switch');
  32. button?.click();
  33. break;
  34. case 'm':
  35. button = document.querySelector('button.pzp-pc-volume-button');
  36. button?.click();
  37. break;
  38. case 't':
  39. button = document.querySelector('button.pzp-pc-viewmode-button');
  40. button?.click();
  41. break;
  42. case 'f':
  43. button = document.querySelector('button.pzp-pc-fullscreen-button');
  44. button?.click();
  45. break;
  46. }
  47. }
  48. };
  49. document.removeEventListener('keydown', existingListener);
  50. document.addEventListener('keydown', existingListener);
  51. if (adBlockInterval) {
  52. clearInterval(adBlockInterval);
  53. adBlockInterval = null;
  54. }
  55. return true;
  56. }
  57. return false;
  58. }
  59.  
  60. function handlePlaybackButton() {
  61. const playbackSwitchButton = document.querySelector('button.pzp-playback-switch');
  62. if (playbackSwitchButton) {
  63. const animateElement = playbackSwitchButton.querySelector('animate');
  64. if (!animateElement) {
  65. playbackSwitchButton.click();
  66. return false;
  67. }
  68. }
  69. if (playbackInterval) {
  70. clearInterval(playbackInterval);
  71. playbackInterval = null;
  72. }
  73. return true;
  74. }
  75.  
  76. function selectHighestQuality() {
  77. const settingsButton = document.querySelector('button[class*="pzp-pc-setting-button"]');
  78. if (!settingsButton) return false;
  79.  
  80. settingsButton.click();
  81.  
  82. const qualityButton = document.querySelector('div[class*="pzp-pc-setting-intro-quality"]');
  83. if (!qualityButton) return false;
  84. qualityButton.click();
  85.  
  86. const qualityOptions = document.querySelectorAll('li[class*="quality-item"]');
  87. let qualityOption = Array.from(qualityOptions).find(option => option.textContent.includes('1080'));
  88. if (!qualityOption) {
  89. qualityOption = Array.from(qualityOptions).find(option => option.textContent.includes('720'));
  90. }
  91. if (!qualityOption) return false;
  92.  
  93. qualityOption.focus();
  94. const enterEvent = new KeyboardEvent('keydown', {
  95. bubbles: true,
  96. cancelable: true,
  97. key: 'Enter',
  98. code: 'Enter',
  99. keyCode: 13,
  100. which: 13
  101. });
  102.  
  103. if (!playbackInterval) {
  104. playbackInterval = setInterval(handlePlaybackButton, 100);
  105. }
  106.  
  107. qualityOption.dispatchEvent(enterEvent);
  108.  
  109. if (qualityInterval) {
  110. clearInterval(qualityInterval);
  111. qualityInterval = null;
  112. }
  113. return true;
  114. }
  115.  
  116. function startIntervals() {
  117. if (!adBlockInterval) {
  118. adBlockInterval = setInterval(handleAdBlockPopup, 100);
  119. }
  120. if (!qualityInterval) {
  121. qualityInterval = setInterval(selectHighestQuality, 100);
  122. }
  123. }
  124.  
  125. // Listen for click events
  126. document.addEventListener('click', () => {
  127. if (location.href !== lastUrl) {
  128. lastUrl = location.href;
  129. if (lastUrl.includes('/live/') || lastUrl.includes('/video/')) {
  130. startIntervals();
  131. }
  132. document.body.style.overflow = 'auto';
  133. document.documentElement.style.overflow = 'auto';
  134. document.body.style.position = 'relative';
  135. document.documentElement.style.position = 'relative';
  136. }
  137. });
  138. // Execute once when page loads
  139. startIntervals();
  140.  
  141. })();