ADIN / ShowUp.tv - Ulubieni bez limitu

// ==UserScript==
// @name          ShowUp.tv - Ulubieni bez limitu
// @namespace     https://openuserjs.org/users/ADIN
// @description	  Dodawaj do ulubionych nieograniczoną ilość transmitujących.
// @author        ADIN
// @homepage      http://www.ad1n.tk
// @include       http://showup.tv/*
// @require       http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js
// ==/UserScript==
var content = $.ajax({
    url: 'index.php',
    async: false
}) .responseText;
var content = $(content);
content.find('.stream') .each(function (index) {
    nazwa = $(this) .find('.stream-name') .html();
    obrazek = $(this) .find('.lazy') .attr('data-original');
    uid = obrazek.substring(6, obrazek.length - 4);
    //sessionStorage.clear();
    sessionStorage.setItem(uid, nazwa)
    //alert( index + ": " + uid);
});
nazwa = $('.white-username') .text();
$('.rounded-tab') .before('<div class="dodaj_ulubione">Dodaj Do Ulubionych <span class="uid" >' + nazwa + '</span></div>');
uid = sessionStorage[nazwa];
$(document.body) .on('click', '.dodaj_ulubione', function () {
    var nazwa = $(this) .find('.uid') .text();
    localStorage.setItem(nazwa, nazwa)
    dialog_ulubione.append('<div><a href="http://showup.tv/' + localStorage.getItem(nazwa) + '">' + localStorage.getItem(nazwa) + '</a><span class="skasuj"> X </span></div>');
});
var lista_online = [
];
$.getJSON(siteUrl + '/site/favorites/', {
}, function (json) {
    var online = json.online;
    var dialog = $('<div />') .dialog({
        title: 'Online',
        width: 100,
        open: function (event, ui) {
            $(event.target) .parent() .css('position', 'absolute');
            $(event.target) .parent() .css('top', '5px');
            $(event.target) .parent() .css('left', '10px');
        },
        closeText: ' X '
    });
    for (var i = 0; i < online.length; i++) {
        if (sessionStorage.getItem(((Number(online[i].small_img) - 1) .toString())) != null) {
            // jak online
            dialog.prepend('<div><a href="http://showup.tv/' + sessionStorage.getItem(((Number(online[i].small_img) - 1) .toString())) + '">' + sessionStorage.getItem(((Number(online[i].small_img) - 1) .toString())) + '</a></div>');
            // pobierz nazwe    
            lista_online.push(sessionStorage.getItem(((Number(online[i].small_img) - 1) .toString())));
        }
    }
    pokarz_online();
});
var dialog_ulubione = $('<div />') .dialog({
    title: 'Ulubione',
    width: 100,
    open: function (event, ui) {
        $(event.target) .parent() .css('position', 'fixed');
        $(event.target) .parent() .css('top', '5px');
        $(event.target) .parent() .css('left', ($(window) .width() - 150) + 'px');
    },
    closeText: ' X '
});
function pokarz_online() {
    dialog_ulubione.append('ONLINE<br><br>');
    for (var key in localStorage) {
        if ($.inArray(localStorage[key], lista_online) !== - 1) {
            dialog_ulubione.append('<div><a href="http://showup.tv/' + localStorage[key] + '">' + localStorage[key] + '</a><span class="skasuj"> X </span></div>');
            //alert(key + ':' + localStorage[key] + " - " +[1]);
        }
    }
    dialog_ulubione.append('<br>OFFLINE<br><br>');
    for (var key in localStorage) {
        if ($.inArray(localStorage[key], lista_online) == - 1) {
            dialog_ulubione.append('<div><a href="http://showup.tv/' + localStorage[key] + '">' + localStorage[key] + '</a><span class="skasuj"> X </span></div>');
        }
    }
}
$(document.body) .on('click', '.skasuj', function () {
    nazwa = $(this) .parent() .find('a') .text();
    $(this) .parent() .remove();
    localStorage.removeItem(nazwa);
});