-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCHZZK-Ad-Blocker.user.js
77 lines (67 loc) · 3.07 KB
/
CHZZK-Ad-Blocker.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// ==UserScript==
// @name CHZZK Ad Blocker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 광고를 빠르게 넘기기 위해 비디오 재생 속도를 최대한 빠르게 설정합니다
// @author krkarma777
// @match https://chzzk.naver.com/*
// @icon https://ssl.pstatic.net/static/nng/glive/icon/favicon.png
// @updateURL https://raw.githubusercontent.com/krkarma777/UltraFastAdSkipperFromCHZZK/main/CHZZK-Ad-Blocker.user.js
// @downloadURL https://raw.githubusercontent.com/krkarma777/UltraFastAdSkipperFromCHZZK/main/CHZZK-Ad-Blocker.user.js
// @run-at document-start
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 광고 비디오를 식별하기 위한 URL 패턴 목록
const adVideoPatterns = [
"*://*tvetamovie.pstatic.net/*",
"*://*glad-vod.pstatic.net/*"
];
// 와일드카드 패턴을 정규 표현식으로 변환
const adVideoUrls = adVideoPatterns.map(pattern => new RegExp(pattern.replace(/\*/g, '.*').replace(/\./g, '\\.')));
// URL이 광고 비디오인지 확인
function isAdVideo(url) {
return adVideoUrls.some(regex => regex.test(url));
}
// 비디오를 빠르게 진행하기 위해 currentTime을 증가시키는 함수
function fastForwardVideo(video) {
if (video && !video.dataset.adSkipperProcessed) {
video.dataset.adSkipperProcessed = true;
console.log(`비디오를 빠르게 진행 중: ${video.src}`);
const interval = setInterval(() => {
if (video.currentTime < video.duration) {
video.currentTime += 10.0; // 이 값을 증가시켜 더 빨리 넘기기
} else {
clearInterval(interval);
}
}, 10); // currentTime 업데이트 빈도를 증가시켜 더 빨리 넘기기
}
}
// 비디오 요소에 이벤트 리스너를 추가하는 함수
function addVideoEventListeners(video) {
video.addEventListener('loadedmetadata', () => {
if (isAdVideo(video.src)) {
fastForwardVideo(video);
}
});
}
// MutationObserver를 설정하여 새로운 비디오 요소를 감지하고 처리
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach(node => {
if (node.nodeType === 1 && node.tagName === 'VIDEO') {
addVideoEventListeners(node);
} else if (node.nodeType === 1) {
node.querySelectorAll('video').forEach(addVideoEventListeners);
}
});
});
});
observer.observe(document.documentElement, { childList: true, subtree: true });
// 페이지 로드 시 비디오 요소 초기 스캔
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('video').forEach(addVideoEventListeners);
});
console.log("CHZZK Ad Blocker 스크립트가 실행 중입니다.");
})();