sarah_pdx / Steephill Players: Remove iframe wrapper

// ==UserScript==
// @name         Steephill Players:  Remove iframe wrapper
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Videos played from "steephill.tv" are opened in a wrapper page with the video
//               in an iframe.  This script removes the wrapper page and shows only the video.
// @author       You
// @match        http://www.steephill.tv/players/*
// @exclude      http://www.steephill.tv/players/profile/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // find twitter video like this:
    //   ... <blockquote class="twitter-video" lang="en"><a href="https://twitter.com/CyclingHubTV/status/751803200404131840"></a></blockquote> ...
    var tw_vid = document.querySelectorAll("blockquote.twitter-video > a");
    if (tw_vid.length) {
        location.replace(tw_vid[0].getAttribute("href"));
        return;
    }

    // find shockwave video like this:
    //   ... <div style="..." align=center><object type="application/x-shockwave-flash" data="http://www.eitb.eus/resources/flash/video_player.swf" ...>
    var sw_vid = document.querySelectorAll('body > div > object[type="application/x-shockwave-flash"]');
    if (sw_vid.length) {
        // bail out.  no good redirect here.
        return;
    }

    // find first iframe (assumption)
    var iframes = document.getElementsByTagName("iframe");
    var src = iframes[0].src;
    
    // massage youtube links a bit
    //alert(src);
    src = src.replace("youtube.com\/embed\/","youtube.com/watch?v=");
    //alert(src);

    
    // don't go into facebook iframes - something went wrong
    if ( src.indexOf("facebook.com/plugins/like.php") >= 0 ) {
        return;
    }
    
    // redirect to first iframe source page
    location.assign(src);

})();