// Morning Becomes Eclectic hack
// by Daniel Hsu

// This Greasemonkey script allows the Morning Becomes Eclectic media to be
// handled by an external application rather than just browser plugins (or
// whatever handles embedded media). This is done by redirecting the
// browser directly to the SMIL document upon loading an MBE show pop-up
// window.

// ==UserScript==
// @name          Morning Becomes Eclectic hack
// @namespace     http://hkn.eecs.berkeley.edu/~dhsu/
// @description   Redirect from MBE pop-up windows to SMIL documents.
// @include       http://www.kcrw.com/music/programs/mb/mb*
// ==/UserScript==

var scripts;
var regex = new RegExp("http://media.kcrw.com/[^\"\']+", "g");
scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
    result = regex.exec(scripts[i].innerHTML);
    if (result) {
        window.location.href = result[0];
        break;
    }
}

