Auto Close YouTube Ads

Close and/or Mute YouTube ads automatically!

< Feedback on Auto Close YouTube Ads

Question/comment

§
Posted: 2018-11-08
Edited: 2018-11-08

Yep, stopped working (fixed, see fix in comments)

Ad muting and auto skipping is no longer working. Tried on latest versions of Chrome and Firefox.

§
Posted: 2018-11-08
Edited: 2018-11-08

Fixed it.

Looks like the selectors are no longer valid.

How to fix:

  1. Go edit the script
  2. Replace all instances of '.videoAdUiSkipButton' with '.ytp-ad-skip-button'
  3. Replace all instances of '.close-padding.contains-svg,a.close-button' with '.ytp-ad-overlay-close-button'
  4. Replace all instances of '.videoAdUi' with '.ytp-ad-player-overlay'

I've been hunting for a skippable video ad for a while to test it, but haven't gotten any lol All the other changes I tested to be working.

fuzetsuAuthor
§
Posted: 2018-11-08

Hey! Sorry for not fixing this sooner despite the other reports. I think youtube is still phasing in this css change because the script still works for me.

On my github I've already had a beta version with some new features for a while, but before I release that I'll make it compatible with both the old and new selectors.

§
Posted: 2018-11-09

@fuzetsu said: Hey! Sorry for not fixing this sooner despite the other reports. I think youtube is still phasing in this css change because the script still works for me.

On my github I've already had a beta version with some new features for a while, but before I release that I'll make it compatible with both the old and new selectors.

Sounds good. Keep up the great work! :)

fuzetsuAuthor
§
Posted: 2018-11-09

Thanks :smile:

Actually, if you get a chance would you mind looking for these css selectors for me? (since I can't see them).

The area that holds the length of a playing ad: The area that tells you how long until you can skip:

§
Posted: 2018-11-09
Edited: 2018-11-09

@1N07 said: Fixed it.

Looks like the selectors are no longer valid.

How to fix:

  1. Go edit the script
  2. Replace all instances of '.videoAdUiSkipButton' with '.ytp-ad-skip-button'
  3. Replace all instances of '.close-padding.contains-svg,a.close-button' with '.ytp-ad-overlay-close-button'
  4. Replace all instances of '.videoAdUi' with '.ytp-ad-player-overlay'

I've been hunting for a skippable video ad for a while to test it, but haven't gotten any lol All the other changes I tested to be working.

Firstly, thank you for posting the fix for the script and getting it working again. I really appreciate it.

Secondly, is there a way to implement another ad to be closed via this script? I would love to have it auto close these ads as well.

https://i.imgur.com/8OeHwhc.png https://i.imgur.com/YdOg4RX.png https://i.imgur.com/QpXlYQF.png

EDIT: Also after using the new script for a while it doesn't actually wait to skip ads. If there is an ad it immediately skips them. Is this change intended or something that just is a product of the new instances in the code? Thanks again.

fuzetsuAuthor
§
Posted: 2018-11-10
Edited: 2018-11-18

I think I'm going to post the new update soon, although I'm still missing those few selectors from above.

If someone can test out the new version and let me know how it works, you can install it here: https://github.com/fuzetsu/userscripts/raw/master/auto-close-youtube-ads/auto-close-youtube-ads.user.js

@"Noah Kesterson" I'll look into including those ads as well. They're not on a video page so they're a bit out of scope, but it's a good suggestion.

If you want to try adding that kind of thing to the script yourself you could just add the selectors for the close buttons on those ads here in the script: https://github.com/fuzetsu/userscripts/blob/2c534c7957e7d0a49666a76f883842a142828f5b/auto-close-youtube-ads/auto-close-youtube-ads.user.js#L25

Line 25 there, add the selectors separated by a comma. Might just work. It would have to be the close button for the ad itself.

§
Posted: 2018-11-15
Edited: 2018-11-15

@fuzetsu said: I think I'm going to post the new update soon, although I'm still missing those few selectors from above.

If someone can test out the new version and let me know how it works, you can install it here: https://github.com/fuzetsu/userscripts/raw/2c534c7957e7d0a49666a76f883842a142828f5b/auto-close-youtube-ads/auto-close-youtube-ads.user.js

@"Noah Kesterson" I'll look into including those ads as well. They're not on a video page so they're a bit out of scope, but it's a good suggestion.

If you want to try adding that kind of thing to the script yourself you could just add the selectors for the close buttons on those ads here in the script: https://github.com/fuzetsu/userscripts/blob/2c534c7957e7d0a49666a76f883842a142828f5b/auto-close-youtube-ads/auto-close-youtube-ads.user.js#L25

Line 25 there, add the selectors separated by a comma. Might just work. It would have to be the close button for the ad itself.

The updated beta version works! An ad played on Youtube and was immediately blacked out and skipped. The only problem is that the ad is not muted.

fuzetsuAuthor
§
Posted: 2018-11-15
Edited: 2018-11-15

@"Anneliese Keeton" Glad to hear the beta version works! Regarding it not muting the video do you think you could check to see if the selector has changed?

the current selector for me is .ytp-mute-button (and the script mutes fine).

Maybe for those of you that have the updated version of Youtube it's different, if you right and inspect element on the mute button what do you see?

EDIT: Also double check the settings to make sure ad muting is still turned on, I added a UI for the settings and changed how they're stored so it's possible that setting got lost when you updated. Although there's supposed to be some code to transfer it properly.

§
Posted: 2018-11-25

@fuzetsu I've tried out your new version from github and it all works well apart from the auto mute functionality.

The waitForAds() function throws an "object is null" exception on "if (!isShort) setupCancelDiv(ad)".

Digging deeper into the setupCancelDiv(ad) function the exception seems to occur on "const skipText = util.get(skipArea, 'firstChild.textContent')".

I can't figure out why as skipArea is not null. However the firstChild.textContent is an empty string.

If I comment out the "if (!isShort) setupCancelDiv(ad)" line in waitForAds() the ad is auto muted as expected.

I will try and find a solution but my javascript skills are very rusty these days!

Thanks.

fuzetsuAuthor
§
Posted: 2018-11-26

@skeandu Thanks for the info :smile:

I just pushed a potential fix. I know you said that skipArea isn't null but I can't see any other reason that it would crash.

It turns out I had a small bug in the util.get function where if the value was null (like skipArea would be if util.q couldn't find it) then it would crash when accessing the first property instead of exiting early and returning null like it is supposed to.

That still means I need the new selector for skipArea for that feature to work properly, but hopefully the fix will at least make the muting work in the mean time.

Install link: https://github.com/fuzetsu/userscripts/raw/master/auto-close-youtube-ads/auto-close-youtube-ads.user.js

Update diff: https://github.com/fuzetsu/userscripts/commit/6d8cbd9aa47e55ad02511c79a3b51cfff9170b40

§
Posted: 2018-11-26

@fuzetsu Yes, that fixed it. Thanks :)

§
Posted: 2018-12-08

That worked! Thank you :)

§
Posted: 2018-12-29

Tested the beta script and it works great. Thanks! Feel free pushing the update so my friends on the standard script edition gets it too :)

fuzetsuAuthor
§
Posted: 2019-01-01

I pushed the update FYI!

Post reply

Sign in to post a reply.