There are 2 previous versions of this script.
// Keseht-TV video for mac user script
// version 1.3
// 2008-09-08
// Copyright (c) 2007, 2008 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 "Keseht-TV video for mac", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Keseht-TV video for mac
// @namespace tag:yehudab@gmail.com,2007-01-29:gm
// @description Fix display issues and video playback of Kesht-TV (Israel channel 2). Version: 1.3
// @include http://www.keshet-tv.com/
// @include http://www.keshet-tv.com/default.aspx*
// @include http://www.keshet-tv.com/*/LobbyVideo.aspx*
// @include http://www.keshet-tv.com/Ambatia/MediaPage.aspx*
// @include http://www.keshet-tv.com/*/vod.aspx*
// @include http://www.keshet-tv.com/*/forum.aspx*
// @include http://www.keshet-tv.com/UvdaVideoPage.aspx*
// @include http://www.keshet-tv.com/Starborn5/*
// @include http://www.keshet-tv.com/borndancer/*
// @include http://www.keshet-tv.com/VideoPage.aspx*
// @include http://www.keshet-tv.com/NewsLobby.aspx*
// @include http://www.keshet-tv.com/PopupVideo.aspx*
// @include http://www.keshet-tv.com/ProgramVideo.aspx*
// @include http://www.keshet-tv.com/*/videoarchive.aspx*
// @include http://www.keshet-tv.com/BigBrother/*
// @include http://*.keshet-tv.com/*PlayerIframe.aspx*
// @include http://mooma.keshet-tv.com/*
// ==/UserScript==
var isPopupVideo = false;
var isLobbyVideo = false;
var isAmbatia = false;
var isPlayerIFrame = false;
function getPlayerHtml(url, width, height)
{
return "<EMBED type='application/x-mplayer2' width='" + width +"' height='" + height + "' " +
"src='" + url + "' autostart='1' showcontrols='1' loop='0'></EMBED>";
}
function fixComments(id)
{
var element = document.getElementById(id);
if (element != null)
{
var commentRE = /<!--[- ]*-->/g;
element.innerHTML = element.innerHTML.replace(commentRE, "");
}
else
{
GM_log(id + " not found");
}
}
function fixBornDancer()
{
GM_log("borndancer fix");
fixComments("lobbyvideotable");
}
function fixMivzakitzis()
{
GM_log("Mivzakitzis fix");
unsafeWindow.CP_OnInterval = function(){};
unsafeWindow.SetUrl = function(MediaID, CategoryID){
unsafeWindow.CP_Play(unsafeWindow.GetURL()+ MediaID + "&CategoryID=" + CategoryID);
};
var TablePlayer = document.getElementById("TablePlayer");
if (TablePlayer != null)
{
try
{
TablePlayer.parentNode.parentNode.parentNode.parentNode.parentNode.style.paddingLeft = "208px";
}
catch (ex)
{
GM_log("Mivzakitzis fix padding failed");
}
}
}
function fixVideoPage()
{
if (document.getElementById("TablePlayer"))
{
document.getElementById("TablePlayer").style.left = "0px";
}
}
function fixLeft(id, offset)
{
var element = document.getElementById(id);
if (element != null)
{
element.style.left = offset + "px";
}
}
function fixUvda()
{
unsafeWindow.CP_OnInterval = function(){};
fixLeft("waitscreen", 0);
fixLeft("TablePlayer", 0);
}
function fixForum(){
unsafeWindow.ShowMsg = function(id) {
var msg = document.getElementById(id);
if (msg == null)
msg = document.getElementById(id.toUpperCase());
if (msg.style.display == "none")
msg.style.display = "";
else
msg.style.display = "none";
}
}
function findPlayerFrame()
{
var i, l = window.frames.length;
for (i = 0; i < l; i++)
{
try {
if (window.frames[i].location.href.match(/(javascripts|js)\/wmp9\.htm/i))
return i;
}
catch (ex)
{}
}
return -1;
}
if (window.location.href.match(/\/starborn/i))
{
fixBornDancer();
}
unsafeWindow.playerFrameIdx = -2;
unsafeWindow.pickerholder = document.getElementById("pickerholder");
unsafeWindow.CP_Play = function (file) {
var width="344";
var height="258";
var containingDiv = document.getElementById("player");
if (containingDiv == null)
containingDiv = document.getElementById("TablePlayer");
if (containingDiv == null)
{
if (unsafeWindow.playerFrameIdx == -2)
unsafeWindow.playerFrameIdx = findPlayerFrame();
if (unsafeWindow.playerFrameIdx < 0)
{
GM_log("Unable to find player frame", 2);
return;
}
}
if (document.getElementById("TablePlayer"))
{
var tp = document.getElementById("TablePlayer");
tp.style.visibility='visible';
tp.style.left="";
try
{
if (tp.childNodes[3].tagName.toLowerCase() == "table")
{
tp.childNodes[3].style.backgroundRepeat = "no-repeat";
tp.childNodes[3].style.background = "none";
}
}
catch(e)
{
}
}
if (document.getElementById("waitscreen"))
{
document.getElementById("waitscreen").style.display = 'none';
}
if (document.getElementById("lobbyvideotable"))
{
document.getElementById("lobbyvideotable").rows[1].cells[0].style.width="8px";
}
if (isLobbyVideo)
{
width="368";
height="274";
}
else if (isPopupVideo)
{
if (document.getElementById("TablePlayer"))
{
document.getElementById("TablePlayer").style.top='';
}
width="392";
height="292";
}
else if (isAmbatia)
{
width="480";
height="360";
}
if (typeof file == "undefined" && isPlayerIFrame)
{
var MediaID = location.href.match(/MediaID=[0-9]+/i);
if (MediaID != null)
{
MediaID = MediaID[0].split("=")[1];
file = unsafeWindow.GetURL()+ MediaID;
}
GM_log(file)
}
window.setTimeout(function() {
GM_xmlhttpRequest({
method:"GET",
url:file,
onload:function(details) {
if (details.status != 200)
{
GM_log("Unable to load video", 2);
}
else
{
var videoUrl = unescape(details.responseText.match(/http%[^&]*/));
if (containingDiv != null)
{
containingDiv.innerHTML = getPlayerHtml(videoUrl, width, height);
}
else
{
if (document.getElementById("PlayerFrame"))
{
var pf = document.getElementById("PlayerFrame");
pf.width=width;
pf.height=height;
}
window.frames[unsafeWindow.playerFrameIdx].location.href = videoUrl;
}
}
}
});
}, 0);
}
unsafeWindow.CP_Stop = function (file) {
var containingDiv = document.getElementById("player");
if (containingDiv == null)
containingDiv = document.getElementById("TablePlayer");
if (containingDiv != null)
{
containingDiv.innerHTML = "";
}
else
{
if (unsafeWindow.playerFrameIdx == -2)
unsafeWindow.playerFrameIdx = findPlayerFrame();
if (unsafeWindow.playerFrameIdx < 0)
{
GM_log("Unable to find player frame", 2);
return;
}
window.frames[unsafeWindow.playerFrameIdx].location.href = "about:blank";
}
}
function fixNewsLobby()
{
unsafeWindow.ShowEngage = function(){};
fixMessagesPrompt();
fixWaitScreen();
}
function fixHomePage()
{
GM_log(1)
fixMessagesPrompt();
}
function fixMessagesPrompt()
{
var m = document.getElementById("messageslink");
if (m != null)
{
m.style.display = "inline";
m.style.cssFloat = "none";
}
}
function fixTickerFrame()
{
var t = document.getElementById("tickerframe");
if (t != null)
{
t.style.display = "inline";
t.style.cssFloat = "none";
t.style.marginRight = "72px";
}
}
function fixMoomaSearch()
{
if (window.location.href.match(/mooma/i))
{
var s = document.getElementById("Select1");
if (s != null && s.name == "guide")
s.id = "guide";
}
}
function fixWaitScreen()
{
if (document.getElementById("waitscreen"))
document.getElementById("waitscreen").style.left = "";
}
function skipAdd(objId, clipURL, width, height)
{
try
{
GM_log(clipURL);
window.setTimeout(function() {
GM_xmlhttpRequest({
method:"GET",
url:clipURL,
onload:function(details) {
if (details.status != 200)
{
GM_log("Unable to load video: " + clipURL, 2);
}
else
{
var videoUrl = clipURL;
var allTags = details.responseText.match(/<[^>]+>/g);
var i, l = allTags.length;
var inEntry = false;
var canSkip = true;
var tagName;
var haveVideoURL = false;
for (i = 0; i < l; i++)
{
tagName = allTags[i].match(/[a-zA-Z]+/);
if (tagName != null)
{
tagName = tagName[0].toLowerCase();
switch (tagName)
{
case "entry":
if (!inEntry)
{
inEntry = true;
canSkip = true;
haveVideoURL = false;
}
else
{
inEntry = false;
if (canSkip && haveVideoURL)
{
GM_log(videoUrl);
document.getElementById(objId).innerHTML = getPlayerHtml(videoUrl, width, height);
return;
}
}
break;
case "param":
paramName = allTags[i].match(/name[ ]*=[ ]*"[^"]+"/i);
paramValue = allTags[i].match(/value[ ]*=[ ]*"[^"]+"/i);
if (paramValue != null && paramName != null)
{
paramName = paramName[0].replace(/^.*"([^"]+)".*$/, "$1").toLowerCase();
paramValue = paramValue[0].replace(/^.*"([^"]+)".*$/, "$1").toLowerCase();
if (paramName == "canskipforward" && (paramValue == "no" || paramValue == "false"))
canSkip = false;
}
break;
case "ref":
if (canSkip)
{
var href = allTags[i].match(/href[ ]*=[ ]*"[^"]+"/i);
if (href != null)
{
videoUrl = href[0].replace(/^.*"([^"]+)".*$/, "$1");
haveVideoURL = true;
}
}
break;
}
}
}
document.getElementById(objId).innerHTML = getPlayerHtml(videoUrl, width, height);
}
}
});
}, 0);
}
catch (ex)
{
GM_log(ex);
}
}
function fixBigBrother()
{
unsafeWindow.BigBrother_DoFSCommand = function(command, args) {
var width, height, bbObjName;
width = 431;
height = 323;
bbObjName = "WMPlayer";
if(command == "WMPlayer_Play")
{
skipAdd(bbObjName, args, width, height);
}
}
fixMessagesPrompt();
fixTickerFrame();
if (document.getElementById("BigBrother"))
{
var src = "BigBrother.swf?cache=GM1.3";
var allEmbed = document.getElementsByTagName("EMBED");
if (allEmbed != null)
{
var i, l = allEmbed.length;
for (i = 0; i < l; i++)
{
if (allEmbed[i].id == "BigBrother")
{
src = allEmbed[i].src;
break;
}
}
}
unsafeWindow.createEmbeddedFlash("flash", "BigBrother", src, 0, 0, 750, 515);
}
}
if (window.location.href.match(/\/vod.aspx/i))
{
fixMivzakitzis();
}
else if (window.location.href.match(/\/UvdaVideoPage.aspx/i))
{
fixUvda();
}
else if (window.location.href.match(/\/forum.aspx/i))
{
fixForum();
}
else if(window.location.href.match(/\/VideoPage/i))
{
fixVideoPage();
fixWaitScreen();
}
else if(window.location.href.match(/\/NewsLobby/i))
{
fixNewsLobby();
}
else if (window.location.href.match(/\/LobbyVideo/i))
{
isLobbyVideo = true;
}
else if (window.location.href.match(/\/PopupVideo/i))
{
isPopupVideo = true;
}
else if (window.location.href.match(/\/ambatia/i))
{
isAmbatia = true;
}
else if (window.location.href.match(/\/PlayerIframe/i))
{
isPlayerIFrame = true;
}
else if (window.location.href.match(/\/item\.aspx/i))
{
fixForum();
}
else if(window.location.href.match(/keshet-tv.com\/$/i) || window.location.href.match(/keshet-tv.com\/default.aspx/i))
{
fixHomePage();
}
else if (window.location.href.match(/BigBrother\//i))
{
fixBigBrother();
}
unsafeWindow.ShowEngage = function(){}
try
{
unsafeWindow.HideEngage();
}
catch(ex)
{
}
function hideFlash1()
{
f1 = document.getElementById("divFlash1");
if (f1 != null)
{
// f1.style.display = "none";
f1.style.cssFloat = "left";
f1.style.height = "422px";
f1.style.overflow = "hidden";
f1.style.width = "145px";
}
}
hideFlash1();
fixMoomaSearch();
