Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ad-skipper + Fix attempt #1762

Open
ImprovedTube opened this issue Sep 12, 2023 · 0 comments
Open

Ad-skipper + Fix attempt #1762

ImprovedTube opened this issue Sep 12, 2023 · 0 comments
Labels
Bug Bug or required update after YouTube changes good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥

Comments

@ImprovedTube
Copy link
Member

ImprovedTube commented Sep 12, 2023

1.) mutationObserver trigger ( there could also be eventListeners)
} else if (id === 'movie_player') {
if (!this.elements.player) {
ImprovedTube.elements.player = node;
// if (this.storage.player_autoplay === false) { ImprovedTube.elements.player.stopVideo(); }
ImprovedTube.elements.video = node.querySelector('video');
ImprovedTube.elements.player_left_controls = node.querySelector('.ytp-left-controls');
ImprovedTube.elements.player_thumbnail = node.querySelector('.ytp-cued-thumbnail-overlay-image');
ImprovedTube.elements.player_subtitles_button = node.querySelector('.ytp-subtitles-button');
ImprovedTube.playerSize();
new MutationObserver(function (mutationList) {
for (var i = 0, l = mutationList.length; i < l; i++) {
var mutation = mutationList[i];
if (mutation.type === 'childList') {
for (var j = 0, k = mutation.addedNodes.length; j < k; j++) {
var node = mutation.addedNodes[j];
if (node.nodeName === 'DIV' && node.className.indexOf('ytp-ad-player-overlay') !== -1) {
ImprovedTube.playerAds(node);
}
}
}
}
}).observe(node, {
attributes: false,
childList: true,
subtree: true
});
new MutationObserver(function (mutationList) {
for (var i = 0, l = mutationList.length; i < l; i++) {
var mutation = mutationList[i];
if (mutation.type === 'attributes') {
if (mutation.attributeName === 'style') {
ImprovedTube.playerHdThumbnail();
}
}
}
}).observe(ImprovedTube.elements.player_thumbnail, {
attributes: true,
attributeFilter: ['style'],
childList: false,
subtree: false
});
}

2.) Function:

ADS
------------------------------------------------------------------------------*/
ImprovedTube.playerAds = function (parent) {
let button = parent.querySelector('.ytp-ad-skip-button.ytp-button') || parent;
// TODO: Replace this with centralized video element pointer
// let video = document.querySelector('.video-stream.html5-main-video');
function skipAd() {
//if (video) video.currentTime = video.duration;
if (button) button.click();
}
if (this.storage.player_ads === 'block_all') {
skipAd();
} else if (this.storage.player_ads === 'subscribed_channels') {
if (!parent.querySelector('#meta paper-button[subscribed]')) {
skipAd();
}
} else if (this.storage.player_ads === 'block_music') {
if (ImprovedTube.elements.category === 'music') {
skipAd();
}
}
};
/*------------------------------------------------------------------------------

  • (new lines by @HanzCEO needn't be commented)


experimental change: 917041b

if (node instanceof Element
&& node.querySelector('ytp-ad-player-overlay, .ytp-ad-text, .ytp-ad-overlay-close-container, ytd-button-renderer#dismiss-button, *[id^="ad-text"], .ytp-ad-skip-button.ytp-button') !== null
){ImprovedTube.playerAds(node);}
}
}
// if (mutation.type === 'attributes' && mutation.attributeName === 'id' && mutation.target.querySelector('*[id^="ad-text"]') )
// {ImprovedTube.playerAds(node);}
}
}).observe(node, {
attributes: false,
// attributes: true,
childList: true,
subtree: true
});



  • misc: CSS for banners:
    4.2 ADS
    ------------------------------------------------------------------------------*/
    html[it-ads=subscribed_channels] #related #player-ads,
    html[it-ads=subscribed_channels] #masthead-ad,
    html[it-ads=subscribed_channels] *[target-id*='engagement-panel-ads'],
    html[it-ads=subscribed_channels] .ytd-ad-slot-renderer,
    html[it-ads=subscribed_channels] yt-mealbar-promo-renderer,
    html[it-ads=subscribed_channels] #player .ytp-ad-image-overlay,
    html[it-ads=block_all] #related #player-ads,
    html[it-ads=block_all] #masthead-ad,
    html[it-ads=block_all] *[target-id*='engagement-panel-ads'],
    html[it-ads=block_all] .ytd-ad-slot-renderer,
    html[it-ads=block_all] yt-mealbar-promo-renderer,
    html[it-ads=block_all] #player .ytp-ad-image-overlay {
    display: none !important;}
    html[it-ads=subscribed_channels] #player .video-ads .ytp-ad-player-overlay-flyout-cta,
    html[it-ads=subscribed_channels] #player .ytp-ad-module .ytp-ad-player-overlay-flyout-cta,
    html[it-ads=block_all] #player .video-ads .ytp-ad-player-overlay-flyout-cta,
    html[it-ads=block_all] #player .ytp-ad-module .ytp-ad-player-overlay-flyout-cta{
    display: none !important;}
    /*
    html[it-ads=subscribed_channels] #player .video-ads,
    html[it-ads=subscribed_channels] #player .ytp-ad-module,
    html[it-ads=block_all] #player .video-ads,
    html[it-ads=block_all] #player .ytp-ad-module {
    opacity: 0.0001 !important;
    }
    html[it-ads=subscribed_channels] #player .ytp-ad-preview-image,
    html[it-ads=block_all] #player .ytp-ad-preview-image,
    html[it-ads=subscribed_channels] #player .ytp-ad-skip-button-container,
    html[it-ads=block_all] #player .ytp-ad-skip-button-container {
    opacity: 0.5 !important;
    }
    */
    /*------------------------------------------------------------------------------
    • (commented because hiding CSS parent elements must also hide child elements, including the skip button)
@ImprovedTube ImprovedTube added Bug Bug or required update after YouTube changes help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥ labels Sep 12, 2023
@ImprovedTube ImprovedTube changed the title [needs update:] Ad-skipper (+ Fix attempts) Ad-skipper + Fix attempt Sep 12, 2023
ImprovedTube added a commit that referenced this issue Sep 29, 2023
ImprovedTube added a commit that referenced this issue Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug or required update after YouTube changes good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥
Projects
None yet
Development

No branches or pull requests

1 participant