tl;dr:
Drag this bookmarklet onto your bookmark bar (only tested in chome). Click it to skip ads.
Here are a couple playback control bookmarklets that work on any HTML5
A little more detail
YouTube wraps their player in a div with a bunch of classes including ad-showing
when an ad is being shown. If your browser is HTML5 compatible, this means you can get the <video>
element fairly easily.
var container = document.getElementsByClassName("ad-showing")[0];
if (container) {
var video_element = container.getElementsByTagName("video")[0];
}
To skip to the end of an HTML video element:
function skip_to_end(video_element){
video_element.currentTime = video_element.duration;
}
How to go from code to bookmarklet
The quick, dirty solution here is to make a bookmarklet like the top of the page by playing a little code golf. This is my quick pass that gets under the character limit for a bookmark:
(function(){var _a=document.getElementsByClassName("ad-showing")[
0];if(_a){var _v=_a.getElementsByTagName("video")[0];_v.currentTi
me=_v.duration}})()
If we wanted to make this a little better, we could wrap it in a setInterval
and make an extension that tries to skip ads at a regular interval. Alternatively, we could set up an event listener.
A comment on HTML5 video
This is kind of a problem if you're an advertiser and want to show ads. Providers like Hulu and CBS make it much harder to skip ads in a few ways. First, they use an iframe, which makes the bookmarklet approach fail because of CORS protection. Extensions don't have this problem, but they use a proprietary player, which is a little harder to work around.