17.12.2015, 23:25
|
#50
|
Чудо-кот
Регистрация: 22.02.2011
Сообщений: 901
Написано 480 полезных сообщений (для 1,471 пользователей)
|
Ответ: Интеграция булочников в Твич
Я имел ввиду что-то типа списка стримов с нужной пометкой (например, ''boolean.name'' в графе ''игра'' на твитче)

Юзерскрипт:

// ==UserScript==
// @name boolean-streams
// @namespace boolean_streamlist
// @include http://forum.boolean.name/*
// @version 1
// @grant none
// ==/UserScript==
var gameTag = "boolean.name";
var refreshDelay = 3000;
var twitch_query_url = 'https://api.twitch.tv/kraken/streams?game='+encodeURI(gameTag);
var streamlist_html = '\
<div id="streamlist" style="position:absolute; right:35px;top:10px; width:250px;height:62px; \
padding:2px; border:3px solid #666458; \
background:#EAE8D3;opacity:0.7; \
color:#21170D; font-size: 13px;"> \
<div id="streamlist-close" style="color:#11070D;cursor:pointer;display:inline-block;">X</div> \
<span style="font-size: 11px; margin-left: 20px;">Перечень действующих видеопотоков</span> \
<div id="streamlist-list" style="overflow:auto; height:45px; background:#CAC8A3; background: \
repeating-linear-gradient(0deg, #CAC8A3,#CAC8A3 15px,#DAD8B3 15px,#DAD8B3 30px); \
background-attachment:local;"> \
</div> \
</div> \
';
var streamlist_minimized_html = '\
<div id="streamlist-show" style="cursor:pointer; position:absolute; right:35px;top:10px; opacity:0.6;"> \
<img alt="Стримы" src="https://cdn2.iconfinder.com/data/icons/picons-basic-2/57/basic2-148_play_video_youtube-128.png" height="30"> \
</div>';
var streamlist_bubble_html = '\
<div id="streamlist-bubble" style="display:none; right:55px;top:86px; position:absolute;z-index:2; \
width:310px;height:90px; background:#EAE8D3;"> \
<img id="streamlist-bubble-avatar" height="32"></img> \
<span id="streamlist-bubble-info" style="font-size:10px; opacity:0.8;"></span><br> \
<img id="streamlist-bubble-preview" height="40"></img> \
<div id="streamlist-bubble-desc" style="vertical-align:top; font-size:11px; \
display:inline-block; width:150px;height:40px;"></div> \
</div>';
if(localStorage.sl==null) localStorage.sl = true;
function streamlist_hide(show){
if(show!==null) localStorage.sl = show;
$("#streamlist" ).css("display",(localStorage.sl=="true" )?"block":"none");
$("#streamlist-show").css("display",(localStorage.sl=="false")?"block":"none");
if(localStorage.sl=="true") streamlist_update();
}
function streamlist_update(){
//-- twitch ---------------------------
$.ajax({
url: twitch_query_url,
headers: {
Accept : "application/vnd.twitchtv.v3+json"
},
dataType: "json",
success: function(res){
$("#streamlist-list").html('');
res.streams.forEach(function(stream){
var stream_html = '<a id="stream-twitch-'+stream["_id"]+'" class="twitch-stream" href="'+stream.channel.url+'" style="color:#31271D;">'+stream.channel.display_name+'</a>';
stream_html+= '<img style="float:right; margin-right:10px;" src="https://cdn1.iconfinder.com/data/icons/micon-social-pack/512/twitch-32.png" height="13">';
stream_html+= '<br>';
$("#streamlist-list").append(stream_html);
$("#stream-twitch-"+stream["_id"]).attr("stream-data",JSON.stringify(stream));
});
$(".twitch-stream").hover(function(){
var stream = JSON.parse($(this).attr("stream-data"));
$("#streamlist-bubble").show();
$("#streamlist-bubble-desc").html(stream.channel.status);
$("#streamlist-bubble-info").html("<b>"+stream.channel.name+"</b> (поток начат: "+stream.created_at+")");
$("#streamlist-bubble-avatar").attr("src",stream.channel.logo);
$("#streamlist-bubble-preview").attr("src",stream.preview.medium);
},function(){
$("#streamlist-bubble").hide();
});
},
error: function(request,status,error){
$("#streamlist").html('<div style="color:#aa2211;">Error! '+error+'</div>');
}
});
//-------------------------------------
if(localStorage.sl=="false") return;
setTimeout(streamlist_update,refreshDelay);
}
$(function(){
$(".search").before(streamlist_html + streamlist_minimized_html + streamlist_bubble_html);
$("#streamlist-close").click(function(){ streamlist_hide(false) });
$("#streamlist-show" ).click(function(){ streamlist_hide(true) });
streamlist_hide(null);
});
|
(Offline)
|
|