MSN Israel Video for Mac

By Yehuda B. Last update Mar 21, 2008 — Installed 1,694 times. Daily Installs: 3, 0, 0, 0, 2, 0, 2, 0, 0, 1, 2, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 2, 1, 1, 0, 0, 4, 0
// MSN Israel video for Mac user script
// version 0.2
// 2007-02-15
// Copyright (c) 2007, Yehuda B.
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey 0.6.6 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "MSN Israel video for Mac", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name          MSN Israel Video for Mac
// @namespace     tag:yehudab@gmail.com,2007-01-29:gm
// @description   Fix display issues in MSN Israel Video web site for Mac computers
// @include       http://msnvideo.msn.co.il/video/*
// ==/UserScript==

unsafeWindow.expandTopic = function (element,collapseIfExpanded){
    var children=element.parentNode.childNodes;
    for(var i=1; i<children.length; i+=4){
        if(element==children[i]&&(element.firstChild.innerHTML=="+ "||!collapseIfExpanded)){
			unsafeWindow.videoTrackEvent(unsafeWindow.gLink,'expandTopic',unsafeWindow.gCM,'expand',element.lastChild.innerHTML);
            unsafeWindow.removeClassName(children[i+2],"hidden");
            unsafeWindow.addClassName(children[i],"expanded");
            children[i].firstChild.innerHTML="- ";
        }
        else{
            unsafeWindow.videoTrackEvent(unsafeWindow.gLink,'expandTopic',unsafeWindow.gCM,'hide',element.lastChild.innerHTML);
            unsafeWindow.removeClassName(children[i],"expanded");
            unsafeWindow.addClassName(children[i+2],"hidden");
            children[i].firstChild.innerHTML="+ ";
        }
    }
}

unsafeWindow.isScrollButtonActive = function (element){
    var newPosLeft;
    var playlist=document.getElementById("playlist");
   
       if(element.id=='pll'){        
        newPosLeft=playlist.style.posLeft+(100*1);      
        if(newPosLeft<=0){
            return true;            
        }
        
    }
    
    else{
        newPosLeft=playlist.style.posLeft-(100*1);        
        var offset=Math.min(0,playlist.parentNode.offsetWidth-playlist.offsetWidth);       
        if(newPosLeft>=offset){
            return true;
            
        }
        
    }
    
    return false;
    
}

unsafeWindow.updateScrollButton = function(id){
    var element=document.getElementById(id);
    if(element){
        if(unsafeWindow.isScrollButtonActive(element)){
            element.childNodes[0].style.display="inline";
            element.childNodes[1].style.display="none";
            element.childNodes[2].style.display="none";
            
        }
        
        else{
            element.childNodes[0].style.display="none";
            element.childNodes[1].style.display="none";
            element.childNodes[2].style.display="inline";
            
        }
        
    }
    
}

unsafeWindow.modBack = function (obj,sColor,bPure,titleColor){
    obj=(bPure)?obj:obj.parentNode.parentNode;
    obj.childNodes[1].style.backgroundColor=sColor;
	obj.childNodes[1].lastChild.style.color=titleColor;
}

unsafeWindow.getURLs = function (guids){
	try 
	{
		var file = "http://msnvideo.msn.co.il" + unsafeWindow.sMediaInfoPageURL+"?m=gu&g="+guids;
		var xmlhttp=new XMLHttpRequest();
		xmlhttp.open("GET",file,false);
		xmlhttp.send(null);

		var urls = xmlhttp.responseText.match(/<url>[^<]*<\/url>/g);
		for (var i = 0; i < urls.length; i++)
			urls[i] = urls[i].replace(/<[^>]*>/g, "");
	    return urls;
	
	}
	catch (ex){
		GM_log("error getting URLs: " + ex, 2);
	}
	return new Array(0);
}

unsafeWindow.queueVideoInVideoLibrary = function(guid, url)
{
	unsafeWindow.showMediaPlayer();
	var playerScreen=document.getElementById("playerScreen");
	playerScreen.style.position="relative";
	playerScreen.style.left="-12px";
	showLoading();
	
    playerScreen.innerHTML = "<EMBED type='application/x-mplayer2' id='mediaPlayer' width='344' height='258' " +
		"src='" + url + "' autostart='1' showcontrols='1' loop='0'></EMBED>";
	window.setTimeout("document.getElementById(\"transitionScreen\").style.display=\"none\";document.getElementById(\"playerScreen\").style.visibility=\"visible\"", 3000);
}

function showLoading()
{
	var playerScreen=document.getElementById("playerScreen");
	playerScreen.style.visibility="hidden";
	var transitionScreen=document.getElementById("transitionScreen");
	transitionScreen.style.display = "block";
}

function runOnload()
{
	var allScripts = document.getElementsByTagName("script");
	for (var i = 0; i < allScripts.length; i++)
	{
		if (allScripts[i].event == "onload" && allScripts[i].htmlFor == "window")
		{
			unsafeWindow.eval(allScripts[i].text);
		}
	}
}


if (window.location.href.match(/\/video\/content.aspx/i))
{
	fixContent();
}

function fixContent(){
	var contentTable = document.getElementById("content");
	if (contentTable != null)
	{
		var parentRE = /parentElement/g;
		var firstRE = /firstChild/g;
		var innerHTML = contentTable.innerHTML;
		innerHTML = innerHTML.replace(parentRE, "parentNode");
		innerHTML = innerHTML.replace(firstRE, "childNodes[1]");
		contentTable.innerHTML = innerHTML;
	}

	runOnload();

	var headlines=document.getElementById("headlines");
	if(headlines){
		unsafeWindow.rgHeadlines=headlines.childNodes;
    }	
}