stream wpisów na żywo
当前为
// ==UserScript==
// @name mirko live
// @namespace http://www.wykop.pl/
// @version 0.3
// @description stream wpisów na żywo
// @author You
// @match http://www.wykop.pl/mikroblog/*
// @match http://www.wykop.pl/tag/*
// @match http://www.wykop.pl/wpis/*
// @grant none
// ==/UserScript==
var audio = new Audio('http://www.soundjay.com/switch/switch-7.wav');
var interwal_ms = 100;
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();
console.log('nowy wpis - dodałem');
wykop.bindLazy();
setTimeout(function(){
wykop.checkNewEntries();
}, interwal_ms);
} 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>");
console.log('nowe wpisy - klikam!');
$('#newEntriesCounter > div > a').trigger("click");
//$("#newEntriesCounter").fadeIn();
//$("#rightFooterBoxCounter").show();
//$("#rightFooterBoxCounter").find(".active-counter").text(data.count);
} else {
//$("#rightFooterBoxCounter").hide();
$("#newEntriesCounter").hide().text("");
console.log('brak nowych wpisów!')
setTimeout(function(){
wykop.checkNewEntries();
}, interwal_ms);
}
}
};
$(document).ready(function(){
if (document.location.pathname.match('/live/')) {
wykop.ajaxAutoRefreshJob = 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();
$('#site > div > div.grid.m-reset-float > div > div.nav.bspace.rbl-block > ul:nth-child(3) > li.active').removeClass('active');
$('#site > div > div.grid.m-reset-float > div > div.nav.bspace.rbl-block > ul:nth-child(3)').append('<li class="active"><a href="http://www.wykop.pl/mikroblog/live/"><span style="color: green; font-weight: bold; font-size: 30px; vertical-align: middle;" id="live">•</span><span> live</span></a></li>');
setInterval(function(){
$('#live').css('visibility','hidden');
setTimeout(function(){
$('#live').css('visibility','visible');
},1000)
},2000)
/*
setInterval(function(){
wykop.checkNewEntries();
//$('#newEntriesCounter > div > a').trigger("click");
}, 214);
*/
//wykop.checkNewEntries();
setInterval(function(){
$('#itemsStream > li:nth-child(n+40)').remove();
console.log('usunięto stare wpisy');
},30000);
} else if (document.location.pathname.match('/tag/')){
$('#site > div > div.grid.m-reset-float > div > div.rbl-block.media-header > div > ul:nth-child(4)').append('<li><a href="' + window.location.href + 'live"><span>live</span></a></li>');
} else {
$('#site > div > div.grid.m-reset-float > div > div.nav.bspace.rbl-block > ul:nth-child(3)').append('<li><a href="http://www.wykop.pl/mikroblog/live/"><span style="font-weight: bold; font-size: 30px; vertical-align: middle;" id="live">•</span><span> live</span></a></li>');
}
})