Skip to content

Commit

Permalink
attempt to fix ad-skipping: revert?
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Sep 10, 2023
1 parent 2501a20 commit 917041b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ ImprovedTube.ytElementsHandler = function (node) {
this.blacklist('channel', node);
}
}
} else if (name === 'META') {
if(node.getAttribute('name')) {
} else if (name === 'META') {
if(node.getAttribute('name')) {
//if(node.getAttribute('name') === 'title') {ImprovedTube.title = node.content;} //duplicate
//if(node.getAttribute('name') === 'description') {ImprovedTube.description = node.content;} //duplicate
//if node.getAttribute('name') === 'themeColor') {ImprovedTube.themeColor = node.content;} //might help our darkmode/themes

//Do we need any of these here before the player starts?
//if(node.getAttribute('name') === 'keywords') {ImprovedTube.keywords = node.content;}
} else if (node.getAttribute('itemprop')) {
} else if (node.getAttribute('itemprop')) {
//if(node.getAttribute('itemprop') === 'name') {ImprovedTube.title = node.content;}
//if(node.getAttribute('itemprop') === 'genre') {ImprovedTube.category = node.content;}
if(node.getAttribute('itemprop') === 'genre') {ImprovedTube.category = node.content;}
//if(node.getAttribute('itemprop') === 'channelId') {ImprovedTube.channelId = node.content;}
//if(node.getAttribute('itemprop') === 'videoId') {ImprovedTube.videoId = node.content;}
//The following infos will enable awesome, smart features. Some of which everyone should use.
Expand All @@ -56,7 +57,8 @@ ImprovedTube.ytElementsHandler = function (node) {
//to use in the "how long ago"-feature, not to fail without API key? just like the "day-of-week"-feature above
// if(node.getAttribute('itemprop') === 'uploadDate') {ImprovedTube.uploadDate = node.content;}
}
} else if (name === 'YTD-TOGGLE-BUTTON-RENDERER' || name === 'YTD-PLAYLIST-LOOP-BUTTON-RENDERER') {
}
else if (name === 'YTD-TOGGLE-BUTTON-RENDERER' || name === 'YTD-PLAYLIST-LOOP-BUTTON-RENDERER') {
if (
node.parentComponent &&
node.parentComponent.nodeName === 'YTD-MENU-RENDERER' &&
Expand Down Expand Up @@ -172,14 +174,16 @@ ImprovedTube.ytElementsHandler = function (node) {
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);
}
if (node instanceof Element
&& node.querySelector('ytp-ad-player-overlay, .ytp-ad-text, .ytp-ad-overlay-close-container, ytd-button-renderer#dismiss-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
});
Expand Down
2 changes: 1 addition & 1 deletion js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ 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');
// let video = document.querySelector('.video-stream.html5-main-video');
function skipAd() {
//if (video) video.currentTime = video.duration;
if (button) button.click();
Expand Down

0 comments on commit 917041b

Please sign in to comment.