mirko live

stream wpisów na żywo

当前为 2015-05-15 提交的版本,查看 最新版本

// ==UserScript==
// @name         mirko live
// @namespace    http://www.wykop.pl/
// @version      0.1
// @description  stream wpisów na żywo
// @author       You
// @match        http://www.wykop.pl/mikroblog/live/
// @match        http://www.wykop.pl/tag/*/live/
// @grant        none
// ==/UserScript==

handleDefaultAjaxRefresh = function($el, data) {
	var audio = new Audio('http://www.soundjay.com/switch/switch-7.wav');
    if (data.html) {
        $el = $("#itemsStream");
        var list = $($(data.html).html());
        list.find('.dC').addClass('newComment').css('width','100%');
        $el.prepend(list);
        //list.prependTo($el).hide().slideDown(300, 'linear');
        $el.find('.newComment').animate({
            "border-left-color": 'transparent'
        }, 2000);
        audio.play();
        $("#newEntriesCounter").text("");
        //$("#rightFooterBoxCounter").find(".active-counter").text("");
        //$("#rightFooterBoxCounter").hide();
        wykop.bindLazy();
    } else {
        if (data.count > 0) {
            var lastItem = $(wykop.params.ajaxAutoRefresh.selector);
            var link = wykop.params.ajaxAutoRefresh.url + 'type/' + lastItem.data().type + '/id/' + lastItem.data().id + '/hash/' + wykop.params.hash + '/html/1';
            $("#newEntriesCounter").html("<div class=\"type-light-warning active-annotation\"><a href=\"#\" class=\"dark ajax space\" data-ajaxurl=\"" + link + "\">" + wykop.varietyFromNumber(data.count, ["Pojawił się", "Pojawiły się", "Pojawiło się"]) + " <b class=\"red\">" + data.count + " " + wykop.varietyFromNumber(data.count, ["nowy wpis", "nowe wpisy", "nowych wpisów"]) + "</b>, " + wykop.varietyFromNumber(data.count, ["pokaż go", "pokaż je", "pokaż je"]) + "</a></div>")
            //$("#newEntriesCounter").fadeIn();
            //$("#rightFooterBoxCounter").show();
            //$("#rightFooterBoxCounter").find(".active-counter").text(data.count);
        } else {
            //$("#rightFooterBoxCounter").hide();
            $("#newEntriesCounter").hide().text("");
        }
    }
}

$(document).ready(function(){

	wykop.handleDefaultAjaxRefresh = handleDefaultAjaxRefresh;

	$('head').append('<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">');

	$('#commentFormContainer').parent().hide();
	$('#site > div > div.grid-right.m-reset-float.m-reset-margin.m-reset-width.m-hide').hide();
	$('#site > div > div.grid.m-reset-float > div > div.nav.bspace.rbl-block').children().hide();	

    setInterval(function(){
        wykop.checkNewEntries();
        $('#newEntriesCounter > div > a').trigger("click");
    }, 300);

    setInterval(function(){
    	$('#itemsStream > li:nth-child(n+40)').remove();
    	console.log('usunięto stare wpisy');
    },30000);
})