BULSATCOM IPTV

Bulsatcom IPTV extended.

Version vom 20.05.2015. Aktuellste Version

// ==UserScript==
// @name        BULSATCOM IPTV
// @namespace   bulsat
// @include     *test.iptv.bulsat.com/iptv.php*
// @version     1.0.0
// @grant       none
// @grant       GM_info
// @description Bulsatcom IPTV extended.
// ==/UserScript==

//==============================================================================================================================================================================================================================================================================================
	
var sttngs = ""; var user; var pass; var width; var height; var rmvprg = {}; var catNm = {}; var catPr = {}; var loginCnt = 0; var maxwidth = 720; var d = new Date(); var month = d.getMonth()+1; var day = d.getDate(); var checkDate = d.getFullYear() + '-' + (month<10 ? '0' : '') + month + '-' + (day<10 ? '0' : '') + day;
	
//==============================================================================================================================================================================================================================================================================================

	user 	 = '';					// e-mail
	pass 	 = '';					// парола
     
	defprg 	 = 'bTV HD';			// програма тръгваща по подразбиране
				 
	rmvprg 	 = [					// списък с каналите за изтриване

			   ];
	
	catNm[0] = 'ОБЩИ';
	catPr[0] = [
				'БНТ 1 HD',
				'bTV HD',
				'Nova TV',
				'TV7',
				'Diema',
				'KinoNova',
				'bTV Cinema',
				'bTV Action',
				'bTV Comedy',
				'Kanal 3',
				'TV+ HD',
				'F+',
				'F+ HD',
				'БНТ HD',
				'БНТ 2',
				'BNT world',
				'News 7 HD',
				'ТВ Европа',
				'Bulgaria ON Air',
				'Bulgaria 24',
				'Evrokom',
				'Черно Море',
				'TV 1 HD',
				'Skat',
				'Alfa',
				'bTV Lady',
				'Diema Family',
			   ];
			   
	catNm[1] = 'Спортни';
	catPr[1] = [
				'Ring BG',
				'Nova Sport',
				'Nova Sport HD',
				'Sportal HD',
				'AMS HD',
			   ];
				 			 
	catNm[2] = 'Научно популярни';
	catPr[2] = [
				'Hobby TV',
				'Hobby TV HD',
				'Hobby lov HD',
				'Destination BG HD',
				'Българска история HD',
				'History Channel HD',
				'Travel Channel',
				'Travel TV HD',
				'От близо HD',
				'24 Kitchen',
				'Fiesta TV',
				'Хайде в кухнята HD',
				'Fine Living',
				'Food network HD',
				'Viasat History',
				'Viasat Explorer',
				'Viasat Nature',
				'Outdor HD',
				'Охота и рыбалка',
			   ];
				 			 
	catNm[3] = 'Филмови';
	catPr[3] = [
				'AXN',
				'Cinema + HD',
				'Action + HD',
				'Comedy + HD',
				'TV1000',
				'CBS Drama',
				'CBS Reality',
			   ];
				 			 
	catNm[4] = 'Музикални';
	catPr[4] = [
				'Planeta HD',
				'Planeta',
				'Fan TV HD',
				'Balkanica HD',
				'BOX TV HD',
				'The Voice',
				'City TV',
				'BG Top Music',
				'BG Music Channel HD',
				'Iconcert HD',
				'MTV Hits',
				'MTV Rock',
				'VH1',
				'VH1 Classic',
				'Jukebox HD',
				'Tiankov Music HD',
				'DSTV',
				'DM Sat',
				'Planeta Folk',
				'Fen Folk TV',
				'Folklor TV HD',
				'Tiankov TV HD',
			   ];
				 			 
	catNm[5] = 'Детски';
	catPr[5] = [
				'Super 7',
				'Ekids',
				'CN',
				'Disney channel',
				'Disney Junior',
				'Nick Jr.',
				'Boomerang',
				'nickelodeon',
				'KiKa HD',
				'Duck TV SD',
			   ];
				 			 
	catNm[6] = 'Чуждестранни';
	catPr[6] = [
				'Fashion TV',
				'CNN',
				'Russia Tuday',
				'PTP Планета',
				'Дом кино',
				'RTL HD',
				'RTL 2 HD',
				'Super RTL HD',
				'RTL Nitro HD',
				'VOX HD',
				'Pro 7 HD',
				'ZDF HD',
				'ARD HD',
				'SAT1',
				'3SAT HD',
				'ARTE HD',
				'France 24',
				'France 2',
				'TV5',
				'Euro D',
				'ATV',
				'Al Jazeera',
			   ];
				 			 
	catNm[7] = 'Радиа';
	catPr[7] = [
				'Дарик радио',
				'Radio Focus',
				'Radio Nova',
				'Hristo Botev BNR',
				'horizont',
				'BG radio',
				'veronika',
				'vitosha',
				'njoy',
				'The Voice 2',
				'Radio City',
				'nrj',
				'Radio 1',
				'zrock',
				'tangramegarock',
				'radio1rock',
				'jazzfm',
			   ];
			   
	// Проверка за нова версия
	$.getJSON( "https://dl.dropboxusercontent.com/u/9691030/IPTV/data.txt", function(data) {
		if(data.version != GM_info.script.version) {
			if(localStorage.getItem("checkDate") != checkDate) {
				localStorage.setItem("checkDate", checkDate);
				alert("Има нова версия на скрипта: v" + data.version);
			}
		}
	});
	
//================================================================================================================

	var sUser = localStorage.getItem("user");
	var sPass = localStorage.getItem("pass");
	var sDefprg = localStorage.getItem("defprg");
		
	if(!user) {
		if(sUser) {
			user = sUser;
		}
	}
		
	if(!pass) {
		if(sPass) {
			pass = sPass;
		}
	}
		
	if(sDefprg) {
		defprg = sDefprg;
	}	
					  
//================================================================================================================

$(document).ready(function() {
	
	// Визуални промени	
	$("head").append('<link href="https://dl.dropboxusercontent.com/u/9691030/IPTV/files/favicon.ico" rel="shortcut icon" type="image/x-icon" />');		
	$("#globalheader").remove();
	$("#copyright").remove();
	$("#iptvmenu").remove();
	$("#iptvft").remove();
	$("h3").remove();
		
	$("html").css("cssText", "background:#191C1F;");
	$("body").css("cssText", "background:#191C1F;overflow:hidden;");
	$("#iptvpc").css("cssText", "background:#191C1F;padding-top:0px;");
	$("#wrapper").css("cssText", "margin-top:2000px");
	
    var mySort = setInterval( function() {
		
		$("#login-container").css("cssText", "margin-top:-1800px");
	
		$("#cfg").remove();
		$("#grp").remove();
		$(".clear").remove();
	
		if($("#btv").length) {
			
			// Визуални промени			
			$("#jw_wrapper").css("cssText", "width:100%;height:100%;");
			$("#list").css("cssText", "height:100%;overflow:hidden;");
			
			width = get_width() - 270; height = width / (16/9);
			$("#main").css("cssText", "width:" + (width + 270) + "px;height:" + height  + "px;padding:0;");
			$("#wrapper").css("cssText", "width:" + (width + 270) + "px;height:" + height + "px;margin:0;");
			$("#pl").css("cssText", "width:" + width + "px;height:" + height + "px;");		
			$("#list").css("cssText", "height:" + (height - 33) + "px;overflow:hidden;");
			jwplayer().resize(width,height);
			
			// Всички програми
			var programs = {};
			$("#list a").each(function() {
				var id = $(this).attr('href').match(/\d+/g);
				var name = $(this).find('h2').text(); 
				$(this).attr('rel', (parseInt(id) + 1000));
				$(this).addClass('cat0');
				$(this).css("cssText", "height:58px;");
				if(programs[name]) {
					programs[name + " 2"] = $(this).attr('id');
				}
				else {
					programs[name] = $(this).attr('id');
				}
			});
			
			// Групиране на програмите
			for (i = 10; i >= 0; i--) {
				if(catPr[i]) {
					$.each(catPr[i], function(index, value) { 
						$('#' + programs[value]).removeClass('cat0').addClass('cat'+i);
						$('#' + programs[value]).attr('rel', ((i * 100) + index));
					});
				}
			}
			
			// Изтриване на програмите
			$.each(rmvprg, function(index, value) { 
				$('#' + programs[value]).remove();
			});
			
			// Сортиране на програмите
			$('#list a').sort(function(a, b){
				var e1 = parseInt($(a).attr('rel'))
				var e2 = parseInt($(b).attr('rel'))
				return e1 > e2 ? 1 : e1 < e2 ? -1 : 0;
			}).appendTo('#list')
			
		}	
		
		// Автоматично логване
		if(loginCnt<50) {
			if($('#user').length && $('#pw').length) {
				if(user && pass) {
					$('#user').val(user);
					$('#pw').val(pass);
					$("#auth").trigger('click');
				}
			}
			loginCnt++;
		}
		
		// Спиране на скрипта, задаване на начална програма, добавяне на категориите
		if($("#btv").length) { 
			clearInterval(mySort);
			
			if(programs[defprg]) {
				$("#" + programs[defprg]).get(0).click();
			}
			
			$('<style type="text/css">#epg ul{width:auto;float:left;margin-left:50px;}</style>').appendTo(document.head);
			$('<style type="text/css">.cat{float:left;display:block;width:30px;height:32px;border-left:1px solid #111012;}</style>').appendTo(document.head);
			$('<style type="text/css">.c0{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat0.png") 0 0 no-repeat;} .c0:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat0.png") 0 -32px no-repeat;} .cat-active{background-color:#24292D;background-position: 0 -32px;}</style>').appendTo(document.head);
			$('<style type="text/css">.c1{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat1.png") 0 0 no-repeat;} .c1:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat1.png") 0 -32px no-repeat;} .cat-active{background-color:#24292D;background-position: 0 -32px;}</style>').appendTo(document.head);
			$('<style type="text/css">.c2{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat2.png") 0 0 no-repeat;} .c2:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat2.png") 0 -32px no-repeat;} .cat-active{background-color:#24292D;background-position: 0 -32px;}</style>').appendTo(document.head);
			$('<style type="text/css">.c3{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat3.png") 0 0 no-repeat;} .c3:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat3.png") 0 -32px no-repeat;} .cat-active{background-color:#24292D;background-position: 0 -32px;}</style>').appendTo(document.head);
			$('<style type="text/css">.c4{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat4.png") 0 0 no-repeat;} .c4:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat4.png") 0 -32px no-repeat;} .cat-active{background-color:#24292D;background-position: 0 -32px;}</style>').appendTo(document.head);
			$('<style type="text/css">.c5{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat5.png") 0 0 no-repeat;} .c5:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat5.png") 0 -32px no-repeat;} .cat-active{background-color:#24292D;background-position: 0 -32px;}</style>').appendTo(document.head);
			$('<style type="text/css">.c6{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat6.png") 0 0 no-repeat;} .c6:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat6.png") 0 -32px no-repeat;} .cat-active{background-color:#24292D;background-position: 0 -32px;}</style>').appendTo(document.head);
			$('<style type="text/css">.c7{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat7.png") 0 0 no-repeat;} .c7:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/cat7.png") 0 -32px no-repeat;} .cat-active{background-color:#24292D;background-position: 0 -32px;}</style>').appendTo(document.head);
			$('<style type="text/css">.settings{background: #191C1F url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/settings.png") 0 0 no-repeat;} .settings:hover{background: #24292D url("https://dl.dropboxusercontent.com/u/9691030/IPTV/files/settings.png") 0 -32px no-repeat;}</style>').appendTo(document.head);
			$("#pl").after('<div id="cat" style="width:270px; height:32px; float:left; background:#191C1F; border-bottom:1px solid #111012;"></div>');
			$("#cat").append('<a id="cat0" class="cat c0 cat-active" href="javascript:showCat(0)" title="'+catNm[0]+'"></a>')
			$("#cat").append('<a id="cat1" class="cat c1" href="javascript:showCat(1)" title="'+catNm[1]+'"></a>');
			$("#cat").append('<a id="cat2" class="cat c2" href="javascript:showCat(2)" title="'+catNm[2]+'"></a>');
			$("#cat").append('<a id="cat3" class="cat c3" href="javascript:showCat(3)" title="'+catNm[3]+'"></a>');
			$("#cat").append('<a id="cat4" class="cat c4" href="javascript:showCat(4)" title="'+catNm[4]+'"></a>');
			$("#cat").append('<a id="cat5" class="cat c5" href="javascript:showCat(5)" title="'+catNm[5]+'"></a>');
			$("#cat").append('<a id="cat6" class="cat c6" href="javascript:showCat(6)" title="'+catNm[6]+'"></a>');
			$("#cat").append('<a id="cat7" class="cat c7" href="javascript:showCat(7)" title="'+catNm[7]+'"></a>');
			$("#cat7").after('<a id="settings" class="cat settings" style="width:20px;border-right:1px solid #111012;cursor:pointer;cursor:hand;" title="Настройки"></a>');
			
			sttngs += '<div style="position:absolute;width:100%;padding:20px 25px 25px;background:#000000;border:4px double #ff9e02;color:#fff;">'; 
			sttngs += '<h2 style="width:100%;color:#ff9e02;text-align:center;">BULSATCOM IPTV v' + GM_info.script.version + '</h2>';
			sttngs += '<fieldset style="padding:5px 10px 10px;border:1px solid #fff;">';
			sttngs += '<legend style="padding:0 5px;color:#fff;font-weight:bold;">Автоматично логване</legend>';
			sttngs += '<input style="padding:5px;margin:5px 0;" id="userSave" type="text" value="' + user + '" autocomplete="off" placeholder="Потребител">';
			sttngs += '<input style="padding:5px;margin:5px 0;" id="passSave" type="text" value="' + pass + '" autocomplete="off" placeholder="Парола">';
			sttngs += '</fieldset>';
			sttngs += '<fieldset style="margin:20px 0 0;padding:5px 10px 10px;border:1px solid #fff;">';
			sttngs += '<legend style="padding:0 5px;color:#fff;font-weight:bold;">Програма по подразбиране</legend>';
			sttngs += '<select id="defprgSave" style="width:100%;padding:5px;">';
			$.each(programs, function(index) { 
				sttngs += '<option value="' + index + '"' + (defprg==index ? ' selected="selected"' : '') + '>' + index + '</option>';
			});
			sttngs += '</select>';
			sttngs += '</fieldset>';
			sttngs += '<div style="float:left;width:30%;margin:30px 5px 0;background:#ff9e02;"><a style="width:100%;text-decoration:none;color:#000;font-weight:bold;display:block;text-align:center;padding:2px 0;cursor:pointer;cursor:hand;" id="reset">RESET</a></div>';
			sttngs += '<div style="float:left;width:30%;margin:30px 5px 0;background:#ff9e02;"><a style="width:100%;text-decoration:none;color:#000;font-weight:bold;display:block;text-align:center;padding:2px 0;cursor:pointer;cursor:hand;" href="https://dl.dropboxusercontent.com/u/9691030/IPTV/BULSATCOM_IPTV.user.js">UPDATE</a></div>';
			sttngs += '<div style="float:left;width:30%;margin:30px 5px 0;background:#ff9e02;"><a style="width:100%;text-decoration:none;color:#000;font-weight:bold;display:block;text-align:center;padding:2px 0;cursor:pointer;cursor:hand;" id="save"">SAVE</a></div>';
			sttngs += '</div>';

			$("body").append('<div id="settingsBlock" style="display:none;z-index:999998;position:fixed;top:0;width:100%;height:100%;background:rgba(0,0,0,0.6);"></div>');
			$("body").append('<div id="settingsOptions" style="display:none;z-index:999999;position:fixed;top:100px;width:300px;left:50%;margin-left:-175px;">' + sttngs + '</div>');
			
			$("#settings").click(function() { $("#settingsBlock, #settingsOptions").show() });
			$("#reset").click(function() { localStorage.clear(), location.reload() });
			$("#settingsBlock, #save").click(function() {	
				$("#settingsBlock, #settingsOptions").hide();
				localStorage.setItem("user", $("#userSave").val());
				localStorage.setItem("pass", $("#passSave").val());
				localStorage.setItem("defprg", $("#defprgSave").val());
			});
			
			$("#list a").each(function() { $(this).hide(); });
			$("#list a.cat0").each(function() { $(this).show(); });
						
			if(get_width() < maxwidth) { 
				width = get_width(); height = width / (16/9);
				$("#pl").css("cssText", "width:" + width + "px;height:" + height + "px;");
				$("#main").css("cssText", "width:" + width + "px;height:" + height + "px;padding:0;");
				$("#wrapper").css("cssText", "width:" + width + "px;height:" + height + "px;margin:0;");
				$("#list").css("cssText", "height:" + (height - 73) + "px;overflow:hidden;position:absolute;top:33px;").hide(); 
				$("#cat").css("cssText", "width:270px; height:32px; float:left; background:#191C1F; border-bottom:1px solid #111012;position:absolute;").hide(); 
				$("#epg").css("cssText", "width:" + width + "px;margin-top:-80px;position:relative;").hide(); 
				$("#pl, #list, #cat, #ascrail2000").mouseenter(function(){$("#list, #cat").show();}).mouseleave(function(){$("#list, #cat").hide();});
			    $("#cat, #list, #epg").mouseenter(function(){$("#epg").hide();}).mouseleave(function(){$("#epg").hide();});
				jwplayer().resize(width,height);
			}
			else {
				$("#epg").css("cssText", "width:" + width + "px;margin-top:-80px;position:relative;").hide(); 
				$("#cat, #list, #epg").mouseenter(function(){$("#epg").show();}).mouseleave(function(){$("#epg").hide();});
			}

		}

    }, 200);

	$(window).resize(function() {
		if(get_width() >= maxwidth) { 
			width = get_width() - 270; height = width / (16/9);
			$("#pl").css("cssText", "width:" + width + "px;height:" + height + "px;");
			$("#main").css("cssText", "width:" + (width + 270) + "px;height:" + height  + "px;padding:0;");
			$("#wrapper").css("cssText", "width:" + (width + 270) + "px;height:" + height + "px;margin:0;");
			$("#list").show().css("cssText", "height:" + (height - 33) + "px;overflow:hidden;"); 
			$("#cat").css("cssText", "width:270px; height:32px; float:left; background:#191C1F; border-bottom:1px solid #111012;").show(); 
			$("#epg").css("cssText", "width:" + width + "px;margin-top:-80px;position:relative;").hide(); 
			$("#pl, #list, #cat, #ascrail2000").mouseenter(function(){$("#list, #cat").show();}).mouseleave(function(){$("#list, #cat").show();});
			$("#cat, #list, #epg").mouseenter(function(){$("#epg").show();}).mouseleave(function(){$("#epg").hide();});
		} 
		else { 
			width = get_width(); height = width / (16/9);
			$("#pl").css("cssText", "width:" + width + "px;height:" + height + "px;");
			$("#main").css("cssText", "width:" + width + "px;height:" + height + "px;padding:0;");
			$("#wrapper").css("cssText", "width:" + width + "px;height:" + height + "px;margin:0;");
			$("#list").css("cssText", "height:" + (height - 73) + "px;overflow:hidden;position:absolute;top:33px;").hide(); 
			$("#cat").css("cssText", "width:270px; height:32px; float:left; background:#191C1F; border-bottom:1px solid #111012;position:absolute;").hide(); 
			$("#epg").css("cssText", "width:" + width + "px;margin-top:-80px;position:relative;").hide(); 
			$("#pl, #list, #cat, #ascrail2000").mouseenter(function(){$("#list, #cat").show();}).mouseleave(function(){$("#list, #cat").hide();});
			$("#cat, #list, #epg").mouseenter(function(){$("#epg").hide();}).mouseleave(function(){$("#epg").hide();});
		}
		jwplayer().resize(width,height);
	});
	
	function get_width() {
        var correction = ($(window).width() >= maxwidth ? 270 : 0);
		var h = (($(window).width() - correction) / (16/9))
		if($(window).height() < h) {
			return (($(window).height() * (16/9)) + correction);
		}
		else {
			return $(window).width();
		}
	}
	
});

function showCat(id) {
	$("#cat a").removeClass('cat-active');
	$("#cat #cat"+id).addClass('cat-active');
	$("#list a").each(function() { $(this).hide(); });
	$("#list a.cat"+id).each(function() { $(this).show(); });
	$("#list").getNiceScroll().resize();
}

// Script Insert
var script = document.createElement('script');
script.textContent = showCat;
document.body.appendChild(script);