// ==UserScript==
// @name CHZZK 광고차단 감지 정지 자동 새로고침
// @namespace chzzk-adblock-stall-reload
// @version 1.0
// @description 치지직에서 중앙 큰 재생버튼(aria-label="재생")이 1초 이상 떠있으면(=재생이 멈춘 것으로 판단) 페이지를 자동 새로고침합니다.
// @author you
// @match https://chzzk.naver.com/*
// @run-at document-idle
// @grant none
// ==/UserScript==
(function () {
'use strict';
const TAG = '[CHZZK 정지 감지 새로고침]';
const CHECK_INTERVAL_MS = 300;
const STALL_LIMIT_MS = 1000;
let sinceMs = null;
let reloading = false;
function findBigPlayButton() {
return document.querySelector(
'button.pzp-brand-playback-button[aria-label="재생"], button[aria-label="재생"].pzp-brand-playback-button'
);
}
function isVisible(el) {
if (!el) return false;
if (el.offsetParent === null && getComputedStyle(el).position !== 'fixed') return false;
return true;
}
function check() {
if (reloading) return;
const btn = findBigPlayButton();
const visible = isVisible(btn);
if (visible) {
if (sinceMs === null) {
sinceMs = Date.now();
console.log(TAG, '재생 버튼 감지, 관찰 시작');
} else if (Date.now() - sinceMs >= STALL_LIMIT_MS) {
reloading = true;
console.log(TAG, '1초 이상 지속 확인 → 새로고침');
location.reload();
}
} else {
sinceMs = null;
}
}
setInterval(check, CHECK_INTERVAL_MS);
})();