There are 6 previous versions of this script.
// Mako video user script
// version 0.7
// 2009-06-21
// Copyright (c) 2008, 2009 Yehuda B.
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// ==UserScript==
// @name Mako video
// @description Fix video playback on Mako.co.il . Version 0.7
// @namespace http://yehudab.com
// @include http://*.mako.co.il/*
// @include http://*.castup.net/Customers/KeshetMako/*
// ==/UserScript==
function getPlayerHtml(url, width, height)
{
GM_log(url);
return "<a target=\"_new\" style=\"float:right;color:white;background-color:black;text-decoration:none\" href=\"" + url + "\">\u05dc\u05e6\u05e4\u05d9\u05d4 \u05d9\u05e9\u05d9\u05e8\u05d4</a><br>" +
"<EMBED type='application/x-mplayer2' width='" + width +"' height='" + height + "' " +
"src='" + url + "' autostart='1' showcontrols='1' loop='0'></EMBED>"; // לצפיה ישירה
}
unsafeWindow.KPlayer_DoFSCommand = function(mPlayerID, command, args) {
var width, height, playerID;
width = 431;
height = 323;
if (mPlayerID.indexOf("_") != -1)
{
var arr = mPlayerID.split("_");
mPlayerID = arr[1];
}
var playerID = "wmp_container_" + mPlayerID;
var player = document.getElementById(playerID);
if (player == null)
return;
width = player.offsetWidth;
if (width < 250)
{
var tmpPlayer = player.parentNode;
while(tmpPlayer != null)
{
if (typeof tmpPlayer.className == "string" &&
(tmpPlayer.className.match(/side_bar_width/) || tmpPlayer.className.match(/video_lobby_holder/)))
{
player = tmpPlayer;
width = player.offsetWidth;
break;
}
tmpPlayer = tmpPlayer.parentNode;
}
}
height = Math.round(width*3/4);
if(command == "WMPlayer_Play")
{
var waitScreen = document.getElementById('video_waitscreen_' + mPlayerID);
if (waitScreen != null)
waitScreen.style.display = 'none';
skipAdd(player, unsafeWindow.asxActionURL, width, height);
}
}
unsafeWindow.onClipPlay = function(nChannelId, nClipId,xml) {
unsafeWindow.dText = "";
unsafeWindow.clip = nClipId;
// get the talkbacks in ajax
unsafeWindow.submitAjaxTalkbacks(nChannelId,nClipId);
unsafeWindow.getDescFunc(nClipId); // this function makes the player start
unsafeWindow.getRankFunc(nClipId);
unsafeWindow.saveClip = nClipId;
unsafeWindow.saveChannel = nChannelId;
var playerID = "video_container_videogallerynull";
var player = document.getElementById(playerID);
if (player == null)
return;
width = player.offsetWidth;
if (width < 400)
{
width = 432;
}
height = width*3/4;
var player_url = unsafeWindow.player_url;
if (player_url.match(/^http:\/\/[^.]+.mako.co.il/) == null)
player_url = "http://www.mako.co.il" + player_url;
var URL = player_url + '&videoVCMId=' + nClipId + '¤tChannelId=' + nChannelId + '&cfgName=' + unsafeWindow.cfg + '&galleryName=' + unsafeWindow.gal;
skipAdd(player, URL, width, height);
}
unsafeWindow.KPlayer_Update = function(){}
function skipAdd(obj, clipURL, width, height)
{
if (typeof obj == "string")
obj = document.getElementById(obj);
try
{
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 == null ? 0 : allTags.length;
if (l == 0)
{
GM_log("asx is empty");
return;
}
var inEntry = false;
var canSkip = false;
var foundclientskip = false;
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;
haveVideoURL = false;
if (allTags[i].match(/clientskip="no"/i)) {
canSkip = false;
foundclientskip = true;
}
else if (foundclientskip)
canSkip = true;
}
else
{
inEntry = false;
if (canSkip && haveVideoURL)
{
obj.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;
if (paramName == "title" && paramValue == "intro")
canSkip = false;
}
break;
case "starttime":
canSkip = true;
break;
case "ref":
if (canSkip)
{
var href = allTags[i].match(/href[ ]*=[ ]*"[^"]+"/i);
if (href != null)
{
videoUrl = href[0].replace(/^.*"([^"]+)".*$/, "$1");
haveVideoURL = true;
}
}
break;
}
}
}
obj.innerHTML = getPlayerHtml(videoUrl, width, height);
}
}
});
}, 0);
}
catch (ex)
{
GM_log(ex);
}
}
function fixMakoStyles()
{
unsafeWindow.getScrollY = function()
{
return 0;
}
addGlobalStyle("#id_sideMenuHolder {position:fixed}");
addGlobalStyle(".channel_ticker_title_text {white-space:nowrap}");
}
function fixCastupVideo()
{
var search = location.href.split("?")[1];
if (typeof search == "undefined")
return;
var params = search.split("&");
var clipURL = "";
var width = "100%";
var height = "100%";
var dimentions = location.href.match(/v_([0-9]{3})x([0-9]{3})_/);
if (dimentions)
{
width = dimentions[0];
height = dimentions[1];
}
for (var i = 0; i < params.length; i++)
{
var p = params[i].toLowerCase();
if (p.indexOf("clipurl=") == 0)
{
clipURL = unescape(params[i].split("=")[1]);
}
}
skipAdd(document.body, clipURL, width, height);
}
function fixWaitScreens()
{
var allW = document.getElementsByClassName("video_waitscreen");
var i, l, playerId, matches;
if (allW != null)
{
l = allW.length;
for (i = 0; i < l; i++)
{
matches = allW[i].id.match(/video_waitscreen_(.*)/);
if (matches)
{
playerId = matches[1];
if (allW[i].innerHTML.match(/plugin_install/))
{
allW[i].innerHTML =
//'<img id="img_waitscreen_' + playerId + '" src="http://yehudab.com/apps/monkeyImg.php?w=' + width + 'h=' + height + 'v=' + scriptVer + '" style="width: ' + width + 'px; height: ' + height + 'px;">' +
'<div id="video_play_overlay_' + playerId + '" class="video_play_overlay" onclick="javascript:KPlayer_pressPlay(\'' + playerId + '\');">' +
'<img id="overlay_player_img_' + playerId + '" src="http://rcs.mako.co.il/images/player_small/video_play_over.png" style="z-index: 7; position: absolute; top: 40%; left: 40%; cursor: pointer;">' +
'</div>';
}
else if (allW[i].innerHTML.match(/playerLive/)) {
unsafeWindow.Event.observe(unsafeWindow, 'load' , function(){
var player = eval("unsafeWindow.oPlayer_" + playerId);
player.playVideo = function()
{
var url = unsafeWindow.asxActionURL;
document.getElementById("wmp_container_" + playerId).innerHTML = getPlayerHtml(url, 426, 319);
if (document.getElementById("banner_plasma_frame") != null)
{
document.getElementById("banner_plasma_frame").style.display="none";
}
}
});
}
}
}
}
}
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);
}
}
}
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
if (typeof unsafeWindow.BigBrother_DoFSCommand != 'undefined')
{
fixBigBrother();
}
else if (window.location.href.match(/mako\.co\.il/))
{
fixMakoStyles();
fixWaitScreens();
}
else if (window.location.href.match(/castup\.net/))
{
fixCastupVideo();
}
