stv_panels.js
· 1.1 KiB · JavaScript
Raw
// Copying this into the browser console (when you have a chat tab selected) will open the Twitch panels in a new window.
$.getJSON("http://www.corsproxy.com/api.twitch.tv/api/channels/"+$('.selected')[0].textContent+"/panels",
function(result){
var out = [];
$.each(result,
function(i, field){
var outp = "";
if (field["data"]["link"]) {
outp += "<a href=\"" + field["data"]["link"] + "\">";
}
if (field["data"]["image"]) {
outp += "<img src=\"" + field["data"]["image"] + "\">";
}
if (field["data"]["link"]) {
outp += "</a>";
}
outp += field["html_description"];
out.push(outp);
});
window.open("data:text/html;charset=utf-8," +
encodeURIComponent("<style>\
body{\
background: none repeat scroll 0% 0% #E0E0E0;\
text-rendering: optimizelegibility;\
color: #3B3B3B;\
font-family: Helvetica,Arial,sans-serif;\
font-size: 12px;\
} p {\
margin-bottom: 15px;\
line-height: 18px;\
}\
</style>") +
encodeURIComponent( out.join("") ),
"panels",
"height=600,width=380,status=no,menubar=no,status=no,toolbar=no,scrollbars=yes"
);
});
| 1 | // Copying this into the browser console (when you have a chat tab selected) will open the Twitch panels in a new window. |
| 2 | $.getJSON("http://www.corsproxy.com/api.twitch.tv/api/channels/"+$('.selected')[0].textContent+"/panels", |
| 3 | function(result){ |
| 4 | var out = []; |
| 5 | $.each(result, |
| 6 | function(i, field){ |
| 7 | var outp = ""; |
| 8 | if (field["data"]["link"]) { |
| 9 | outp += "<a href=\"" + field["data"]["link"] + "\">"; |
| 10 | } |
| 11 | if (field["data"]["image"]) { |
| 12 | outp += "<img src=\"" + field["data"]["image"] + "\">"; |
| 13 | } |
| 14 | if (field["data"]["link"]) { |
| 15 | outp += "</a>"; |
| 16 | } |
| 17 | outp += field["html_description"]; |
| 18 | out.push(outp); |
| 19 | }); |
| 20 | window.open("data:text/html;charset=utf-8," + |
| 21 | encodeURIComponent("<style>\ |
| 22 | body{\ |
| 23 | background: none repeat scroll 0% 0% #E0E0E0;\ |
| 24 | text-rendering: optimizelegibility;\ |
| 25 | color: #3B3B3B;\ |
| 26 | font-family: Helvetica,Arial,sans-serif;\ |
| 27 | font-size: 12px;\ |
| 28 | } p {\ |
| 29 | margin-bottom: 15px;\ |
| 30 | line-height: 18px;\ |
| 31 | }\ |
| 32 | </style>") + |
| 33 | encodeURIComponent( out.join("") ), |
| 34 | "panels", |
| 35 | "height=600,width=380,status=no,menubar=no,status=no,toolbar=no,scrollbars=yes" |
| 36 | ); |
| 37 | }); |