diff --git a/content.js b/content.js index 13b94e8..1aad073 100644 --- a/content.js +++ b/content.js @@ -37,6 +37,7 @@ function checkForAds() { if (video) { video.muted = true; storeAdMuteInfo(); + dimVideo(); // Call the function to take a screenshot after storing ad mute info // Request the background script to take a screenshot @@ -51,6 +52,7 @@ function checkForAds() { } else { // Unmute the video if no ad is playing if (video) video.muted = false; + resetVideoBrightness(); } if (skipButton && skipAdOption) { @@ -104,6 +106,19 @@ function checkForAds() { } } +function dimVideo() { + document.querySelectorAll('video.video-stream.html5-main-video').forEach(video => { + video.style.filter = 'brightness(0)'; + video.style.transition = 'filter 0.5s ease'; + }); +} + +function resetVideoBrightness() { + document.querySelectorAll('video.video-stream.html5-main-video').forEach(video => { + video.style.filter = ''; + }); +} + /** * Function to hide image advertisements */ @@ -124,6 +139,8 @@ function hideImageAds() { 'YtwTopBannerImageTextIconButtonedLayoutViewModelHost', 'YtwTopBannerImageTextIconButtonedLayoutViewModelHostBannerImage', // Add other known image advertisement classes here + 'ytp-ad-player-overlay-layout__player-card-container', + 'ytp-ad-player-overlay-layout__ad-info-container', ]; adImageClasses.forEach(adClass => { @@ -132,6 +149,7 @@ function hideImageAds() { adImage.style.display = 'none'; }); }); + } catch (error) { console.error('Error in hideImageAds:', error); }