-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
46 lines (39 loc) · 1.79 KB
/
content.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
const removeAds = () => {
// Menghapus elemen iklan overlay dan modul iklan
const adModules = document.querySelectorAll(".ytp-ad-module, .ytp-ad-player-overlay, .ytp-ad-overlay-container, .ytp-ad-preview-container, .ytp-ad-skip-button, .ytp-ad-image-overlay");
adModules.forEach(ad => {
ad.style.display = "none";
});
// Menghapus iframe yang berasal dari server iklan
const adFrames = document.querySelectorAll("iframe[src*='doubleclick.net'], iframe[src*='googlesyndication.com'], iframe[src*='youtube.com/ads/'], iframe[src*='ytimg.com/vi/'], iframe[src*='youtube.com/embed/']");
adFrames.forEach(ad => {
ad.remove();
});
// Menghapus elemen video iklan dari DOM
const adVideos = document.querySelectorAll("video[src*='ads.youtube.com'], video[src*='googlevideo.com/videoplayback?ad_interstitial=true']");
adVideos.forEach(ad => {
ad.remove();
});
// Menghapus tombol iklan yang bisa di-skip
const skipButton = document.querySelector(".ytp-ad-skip-button");
if (skipButton) {
skipButton.click();
}
// Pastikan video utama tetap terlihat dan tidak hilang
const video = document.querySelector("video.html5-main-video");
if (video) {
video.style.visibility = "visible";
video.style.opacity = "1";
}
// Memastikan thumbnail tetap muncul dengan benar
const thumbnails = document.querySelectorAll("ytd-thumbnail img");
thumbnails.forEach((thumbnail) => {
thumbnail.style.visibility = "visible";
thumbnail.style.opacity = "1";
});
};
// Observasi perubahan di halaman YouTube untuk iklan baru yang dimuat
const observer = new MutationObserver(removeAds);
observer.observe(document.body, { childList: true, subtree: true });
// Jalankan fungsi removeAds setiap detik untuk menghapus iklan yang muncul
setInterval(removeAds, 1000);