Monday, November 21, 2005

Update -- CNN Friendly Video

Updated the script so you can use the old or new method. The old method will replace all anchors with a link directly to the stream. The new method uses CNN's video player but bypasses ads.

cnnfriendlyvideo.user.js

1 comment:

MinhDuc said...

Scrip didn't work with "CNN In The News" http://www.cnn.com/video/nitn/latest/content.htm so I had changed a bit;



// Copyright (c) 2005, Vlajbert
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "CNN Friendly Video", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name CNN Friendly Video
// @namespace http://vlajbert.blogspot.com/
// @description Replaces the video anchors with a link directly to the wmv file.
// @include http://www.cnn.com/video/*
// @version 0.0.4
// ==/UserScript==

// NOTE!!! If you don't want to use cnn's video player then set bypassplayer to 1. This
// will link the videos directoy to the stream.

var bypassplayer = 0;

(function() {
var plyr = document.getElementById('cnnVidPlayer');
if( plyr ) {
var obj = plyr.parentNode;
var p = obj.innerHTML;
var beginRemove = p.indexOf('.ws.asx?NGU');
var endRemove = p.lastIndexOf('">',beginRemove);
obj.innerHTML= p.substring(0,beginRemove) + '.ws_noads.asx' + p.substring(endRemove);
}



function getObject( obj, xpath) {
try { return document.evaluate( xpath, obj, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; }
catch( e) { return null; }
}

function loc() {
var l = document.location.href;
var foo = l.replace( /\?/, "\n");
foo = foo.replace( /&/g, "\n");
return foo;
}

})();

// 0.0.1 Initial release.
// 0.0.2 Changed script from rewriting the anchors to point to the stream to actually usin CNN's video player but forwarding past the ads.
// 0.0.3 Added support for both linking directly to the stream or using cnn's video player.
// 0.0.4 CNN Player has changed the structure of website on Jun 28 2007