rj.viz1987gmail.com / html5_mailCloud_player

// ==UserScript==
// @name    html5_mailCloud_player
// @description Add HTML5 player for mail.ru cloud and play (without downloading the file). 
// @version 1.3
// @author  Max Max
// @license MIT
// @include https://cloud.mail.ru/*
// @match   https://cloud.mail.ru/*
// @icon    http://i62.tinypic.com/292xlib.png
// @run-at  document-end
// ==/UserScript==

if(window.self!=window.top){return}if(!window.location.href.match(/cloud\.mail/)){return}if(!document.getElementById('portal-menu__toolbar')){return} 
function addStyle(b){var a=document.head||document.getElementsByTagName("head")[0],c;if(a){c=document.createElement("style");c.type="text/css";c.appendChild(document.createTextNode(b));a.appendChild(c);}}function ce(a){return document.createElement(a);}function gebid(a){return document.getElementById(a);}function createEl(a,b,d){var c=document.createElement(a);for(attrName in b){c.setAttribute(attrName,b[attrName]);}if(d!=null){c.innerHTML=d;}return c;}function remid(b){var a=document.getElementById(b);if(a){a.parentNode.removeChild(a);}}function _NodesByXPath(a){return document.evaluate(a,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);}function _NodeByXPath(a){return _NodesByXPath(a).snapshotItem(0);}function addClass(b,d){var a=new RegExp("(^|\\s)"+d+"(\\s|$)","g");if(a.test(b.className)){return;}b.className=(b.className+" "+d).replace(/\s+/g," ").replace(/(^ | $)/g,"");}function removeClass(b,d){var a=new RegExp("(^|\\s)"+d+"(\\s|$)","g");b.className=b.className.replace(a,"$1").replace(/\s+/g," ").replace(/(^ | $)/g,"");}function truncate(b,a){return(b.length>a)?b.slice(0,a-1)+"…":b;}(CL={link_arr:[],ext:[],name:[],src:"",type:"",title:"",_lStorageReallyWorks:false,init:function(){if(typeof(localStorage)=="undefined"){alert("Ваш браузер не поддерживает localStorage()");console.log("Ваш браузер не поддерживает localStorage()");}else{this.localStorageReallyWorks=true;if(this.localStorageReallyWorks){console.log("Ваш браузер поддерживает localStorage()");}}try{this.getValues();this.createDiv();}catch(a){this.error(a);}},error:function(a){},msgMonitorStart:function(){var a,b=2200;a=setTimeout(function c(){CL.startIt();a=setTimeout(c,b);},b);},shareCSS:function(){var c,a,b="";icoClose="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAZCAYAAAArK+5dAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB90EBhEoAhwoWowAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAkUlEQVRIx+1VWw7AIAgTLuuZOO32ZbIsiK0Mv8aXJrQor7b228LkeTGza5x778IQzbDiObBBIqyaGQVkfTRDgDxAkXR4RBG5WwMGiJK7AdCvI+TTADtBZimWTIcg9ZNsG65mRY+uiqMpKi1yaZuWDhoDpFcFQ85gNNMhiF5oZoigQRuC83ZkJDPERor2hZWvihuu325Xl02JxQAAAABJRU5ErkJggg==";c="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAO4SURBVHjaxJfPa1xVFMc/7/fM5E2dzI/G6TTa1LQiNSSRSmtpoNJiDWiELqoIXatQ3Fihf0I3bsSN66J0FbAItdGN+ANC1BiKiBU6TMi0Te200aQz05l577iYm3HymvmRMdADb3Xv+X7evfece87VRITHYSbA+S9/6zQvChwBTgIvALuAsBorATeBX4CrwI/AajuxC68dqIO7sL3AIeAwMApEAuMZwAZWgNvAQlcrbmNPAe8DbwPpNvMiwEvqexf4HPgYWGzloLcROwFcBj7oAA1aWvlcVhpbAp8CLqlt7dVGlcapbrf6FeBTIBEc8EXwfcHf5O91XUPXtKBLQmmtATPtwE8DF4BkUKHi+SCQ7LPZ3R8hHqm73ivWWLpf5O6DCmiCbTyyiUml+QeQawU+C4wHPUtVD9vUmRhKcHhPnFSfw/riROCvBxVmcwW+y96jVPUIW0ZQYlxpfxg8YxcYAc4EPco1H8c0OD2WYer5NDvd/6AAmgY7XZvXD6Q5PZrBMQ3KNX+zYz2jGG4z+KgKgoHgmSLC8X0pXhzs7xhNBwdjnNifAoSa/wh8QDGONoNPApMbobBSqpFyQ0zsTXQdyhNDCQZjEbxNF82kYjXOeLw5dXwRar6wP+VybDhJxDa6Bodtg2cSfeRXSgiChhZMsXIzOAOE1qEi8PJwimPDSaKOueUEHojW4+Chio8mdEixGuBQI5iqHof2xJl8bgBT13q6OUbSOwhbOj8vrfD78lo9xzfCN95cNd8nZBkc3N3fMxTAdUzGMjHeHBtk5MkdlKteyyuzrAFVD1zHIh6xtqXmuo7BkaE4YUun6jXqfrkZnAfKhq5RqlR5WK1tW8GPRxz6bIua76PVoflm8LzAgm3q/FOu8GvuzraBC6tF/i6WsQwDVafnm8FXgSsaELZDfPvnMnPXF/83dLVY4utrWSqeYBkaAlcUqxHV3wN5EXnPNvSBohHi0k85rt8s8OyuBGHHrt9iXZqmwf3VEnM37pAt6rjRKIi/DEwD2WbwGnANuOiLfy7s2JS0J/ghv8bcUha9hwiv+oJYYSKuCwgCFxVj0+r0CXBcRMbDtoljxah5Hr10oo6uYRgmOj4izCvtlvU4B5wHPhORpAZYG2+erk0AxEfgrtLMdWp9ZoB3gMJ6wZUePuq7VFBaM932XNPAW920qW1sQWlMb7XL/AaYAj4Cbm0BeEv5TCmNnvrqReAc9Yh8A3i1RUNfVCv8CvhiOxr6dbsBzAIxoNLmCTOr5nbO9cf1aPt3AOgOVOof/FI1AAAAAElFTkSuQmCC";b+=".drop-shadow {-moz-box-shadow: 5px 5px 5px #000; -webkit-box-shadow: 5px 5px 5px #000; box-shadow: 5px 5px 5px #000;}";b+=".one-edge-shadow {-moz-box-shadow: 0 5px 5px #000; -webkit-box-shadow: 0 5px 5px #000; box-shadow: 0 5px 5px #000; }";b+=".no-select {-webkit-user-select: none; -moz-user-select: none; -khtml-user-select: none; user-select: none;}";b+=".slideDown{	animation-name: slideDown;	-webkit-animation-name: slideDown;		animation-duration: 1s;		-webkit-animation-duration: 1s;	animation-timing-function: ease;		-webkit-animation-timing-function: ease;		visibility: visible !important;						}";b+="@keyframes slideDown {	0% {		transform: translateY(-100%);	}	50%{		transform: translateY(8%);	}	65%{		transform: translateY(-4%);	}	80%{		transform: translateY(4%);	}	95%{		transform: translateY(-2%);	}				100% {		transform: translateY(0%);	}		}";b+="@-webkit-keyframes slideDown {	0% {		-webkit-transform: translateY(-100%);	}	50%{		-webkit-transform: translateY(8%);	}	65%{		-webkit-transform: translateY(-4%);	}	80%{		-webkit-transform: translateY(4%);	}	95%{		-webkit-transform: translateY(-2%);	}				100% {		-webkit-transform: translateY(0%);	}	}";b+=".black_overlay {z-index:1001; position:fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; background-color: black; -moz-opacity: 0.5; opacity:.50; filter: alpha(opacity=50); -webkit-transition: opacity 500ms ease-in; -moz-transition: opacity 500ms ease-in; transition: opacity 500ms ease-in;}";b+=".white_content {z-index:1002; position:fixed; width:100%; height:100%; top:0px; left:0px; text-align:center; background-color:transparent; padding-top:85px;}";b+=".space_4px {width:100%; height:4px; margin: 0; padding: 0; }";b+=".main_fieldset {border:1px solid #666; padding:1px; margin:1px; border-radius:4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; float:none;}";b+=".main_legend {color:#333; font-size: 11px;}";b+="#gm_form_fav { opacity: 1.0; display:inline-block; width:640px; background-color:#000; text-align: left; border: 3px groove #ccc;}";b+="#gm_form_fav:hover { opacity: 1;}";b+=".main_title {height:30px; font-size:120%; background-color: #1378c0;}";b+=".main_body {padding: 2px; color: #000; }";b+=".ico_close {background:url("+icoClose+") no-repeat center; width:30px; height:30px; position:absolute; display:block; margin: 0px 5px 0 0;}";b+=".ico_smotri {background:url("+c+") no-repeat center; width:30px; height:30px; position:absolute; display:block; margin: 0px 0 5px 0;}";b+="div.b-datalist__item.b-datalist__item_:nth-child(2n) { background: #E8EDFF; !important; }";b+=".play_btn { opacity: 0.5; color: #fff; background-color: #3a87ad; text-align: center; width:26px; height:26px;}";b+=".play_btn:hover { opacity: 1.0; color: #fff; background-color: #2d6987;}";addStyle(""+b);console.log("CLOUD: стили загружены..");},shareForms:function(){var a;},createDiv:function(){this.shareCSS();this.shareForms();this.RegisterContextMenu();this.msgMonitorStart();console.log("CLOUD: построение форм..");},templateDiv:function(a,g,c,f){var b,d;b='<form class="no-select drop-shadow" id="gm_form_'+a+'" name="gm_form_'+a+'" action="" onsubmit="return false;" onclick=";" >';b+='<div style="width:640px; height:30px; line-height:30px;" class="main_title">';b+='<div style="float:left; width:30px;"><div id="ico_smotri_'+a+'" class="ico_smotri" title=""></div></div>';b+='<div style="float:left; width:570px; font-size: 18px; font-weight: normal; color:#fff; margin: 0px 0px 0px 30px;">&nbsp;'+f+"</div>";b+='<div style="float:right; width:30px;"><div id="ico_close_'+a+'" class="ico_close" title="Click or Esc"></div></div>';b+="</div>";b+='<video controls src="'+g+'" type="video/'+c+'" width="640" height="480"></video>';b+="</form>";d=createEl("div",{style:"display:none;","class":"black_overlay",id:"fade_"+a});document.body.appendChild(d);d=createEl("div",{style:"display:none;","class":"white_content",id:"light_"+a},b);document.body.appendChild(d);},createMediaDiv:function(g,c,f){var a="fav",d,b;b=truncate(f,55);remid("light_"+a);remid("fade_"+a);CL.templateDiv(a,g,c,b);CL.showFavDiv();d=gebid("ico_close_fav");d&&d.addEventListener("click",function(){try{CL.hideFavDiv();}catch(h){CL.error(h);}},false);},showFavDiv:function(){var a=gebid("gm_form_fav");removeClass(a,"slideDown");addClass(a,"slideDown");gebid("light_fav").style.display=null;gebid("fade_fav").style.display=null;},hideFavDiv:function(b){var a=gebid("gm_form_fav");removeClass(a,"slideDown");gebid("light_fav").style.display="none";gebid("fade_fav").style.display="none";remid("light_fav");remid("fade_fav");},startIt:function(){var g=_NodesByXPath('//a[@class="js-href b-datalist__item__link b-datalist__item__link_video"]'),c=_NodesByXPath('//div[@class="b-datalist__item__pic"]'),a,o,b,f;function r(i){i.preventDefault();i.stopPropagation();return false;}if(g.snapshotLength>0){for(var h=0;h<g.snapshotLength;h++){var l=g.snapshotItem(h);var q=l.getAttribute("bcastAltered");if(!q){l.setAttribute("bcastAltered",true);a=l.href;if(a.indexOf("?")!=-1){o=a.indexOf("?");a=a.substring(0,o);}CL.link_arr[h]=a;console.log("SRC: "+CL.link_arr[h]);b=a.split(".");CL.ext[h]=b[b.length-1];f=a.split("/");CL.name[h]=f[f.length-1];}}}if(c.snapshotLength>0){for(var h=0;h<c.snapshotLength;h++){var p=c.snapshotItem(h);var q=p.getAttribute("bcastAltered");if(!q){p.setAttribute("bcastAltered",true);var k=CL.ext[h];switch(k){case"mp4":if(navigator.userAgent.toLowerCase().indexOf("firefox")>-1){break;}var j=k;if(k=="ogv"){j="ogg";}var m=c.snapshotItem(h),d=CL.name[h],t=CL.link_arr[h];m.setAttribute("link",""+t);m.setAttribute("name",""+d);m.innerHTML='<button id="item-'+h+'" class="play_btn">&#9658;</button>';m.addEventListener("click",r,false);m.addEventListener("click",function(){var n=""+this.getAttribute("link"),e=""+j,s=""+this.getAttribute("name"),i=decodeURIComponent(s);CL.createMediaDiv(n,e,i);return false;},false);break;case"ogv":case"webm":var j=k;if(k=="ogv"){j="ogg";}var m=c.snapshotItem(h),d=CL.name[h],t=CL.link_arr[h];m.setAttribute("link",""+t);m.setAttribute("name",""+d);m.innerHTML='<button id="item-'+h+'" class="play_btn">&#9658;</button>';m.addEventListener("click",r,false);m.addEventListener("click",function(){var n=""+this.getAttribute("link"),e=""+j,s=""+this.getAttribute("name"),i=decodeURIComponent(s);CL.createMediaDiv(n,e,i);return false;},false);break;default:break;}}}}console.log("CLOUD: клик по кнопке..");},RegisterContextMenu:function(){},getValues:function(){var a;window.addEventListener("beforeunload",function(b){unsafeWindow=null;CL=null;},false);console.log("CLOUD: чтение значений..");},}).init();