[RESOLVED] How to block banner ads in Youtube ?

General discussion about the NoScript extension for Firefox
Post Reply
danielson
Posts: 2
Joined: Sun Jan 04, 2015 1:11 pm

[RESOLVED] How to block banner ads in Youtube ?

Post by danielson »

Is it possible to block those annoying little banner ads within certain Youtube clips that require you to click on to close them?

BTW, do appreciate how lightweight NoScript is compared to Adblock Plus etc. :)
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.1) Gecko/20141110 Firefox/31.9 PaleMoon/25.1.0
barbaz
Senior Member
Posts: 11066
Joined: Sat Aug 03, 2013 5:45 pm

Re: How to block banner ads in Youtube ?

Post by barbaz »

danielson wrote:Is it possible to block those annoying little banner ads within certain Youtube clips that require you to click on to close them?
Yes, NoScript can do that, but I'm not sure the exact details.

In HTML5 video I think you will need to use a surrogate script like follows to inject a style: (warning: untested)

Code: Select all

noscript.surrogate.youtube_mod.replacement : let selectors=['.video-annotations'];window.addEventListener('load', function(){let s=document.createElement('style');s.setAttribute('type','text/css');s.innerHTML = selectors.join(',\n')+'\n{ display: none !important; }';document.head.appendChild(s);}, false);
noscript.surrogate.youtube_mod.sources : @.youtube.com
That one is supposed to block video annotations, I don't know if it would work as-is on those ads as well. If not you will need to use the inspector (Tools > Web development > Inspect) on one of those ads to find the right selector (take the class attribute and prepend a '.' to one space-separated portion)
If needed you can add other selector as follows: change the "selectors=['.video-annotations']" part to "selectors=['.video-annotations', '.other-thingie-i-dont-want']"

For Flash video try just add this ABE rule to noscript options > advanced > ABE > USER

Code: Select all

Site ^https?://s\.ytimg\.com/.*[^0-9A-Za-z](?:ad|iv)3[^0-9A-Za-z].*
Deny
If that blocks video ads too and you don't want that, try changing '(?:ad|iv)' to just 'iv' and see if the ads you do want blocked are still blocked.
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (Windows NT 5.2; rv:33.0) Gecko/20100101 SeaMonkey/2.30
danielson
Posts: 2
Joined: Sun Jan 04, 2015 1:11 pm

Re: How to block banner ads in Youtube ?

Post by danielson »

Thanks a bunch man! 8-)
Just tried the

Site ^https?://s\.ytimg\.com/.*[^0-9A-Za-z](?:ad|iv)3[^0-9A-Za-z].*
Deny

suggested for starters and it did good! :)

There was only a sticker, stickin' around but that's not too bad.
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.1) Gecko/20141110 Firefox/31.9 PaleMoon/25.1.0
Post Reply