-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
31 lines (28 loc) · 841 Bytes
/
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
// Function to mute or unmute the video
function setMute(mute) {
let video = document.querySelector('video');
if (video) {
console.log(`Setting mute to: ${mute}`);
video.muted = mute;
} else {
console.log('No video element found');
}
}
// Function to detect if an ad is playing
function isAdPlaying() {
let adMarkers = document.querySelectorAll('._1GyF_i9b6_XmG3IxgNlj4H, ._3lBTY-_WfJ1b1MRdoASQNm');
console.log(`Ad markers found: ${adMarkers.length}`);
return adMarkers.length > 0;
}
// Check periodically if an ad is playing
function checkAds() {
if (isAdPlaying()) {
setMute(true);
console.log('Ad is playing, muting video');
} else {
setMute(false);
console.log('Ad is not playing, unmuting video');
}
requestAnimationFrame(checkAds);
}
requestAnimationFrame(checkAds);