Page 1 of 1

[RESOLVED] How to block banner ads in Youtube ?

Posted: Sun Jan 04, 2015 1:15 pm
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. :)

Re: How to block banner ads in Youtube ?

Posted: Sun Jan 04, 2015 6:58 pm
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.

Re: How to block banner ads in Youtube ?

Posted: Sun Jan 04, 2015 7:45 pm
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.