您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button that gives you a .m3u8 file for a current stream.
当前为
// ==UserScript== // @name Twitch url grabber // @description Adds a button that gives you a .m3u8 file for a current stream. // @include *www.twitch.tv* // @include http://api.twitch.tv/api/channels/*/access_token?grabber // @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // @version 0.0.1.20150216190924 // @namespace https://greasyfork.org/users/3167 // ==/UserScript== //var script = "var url='http://usher.justin.tv/api/channel/hls/scream.m3u8?token={%22user_id%22:null,%22channel%22:%22scream%22,%22expires%22:1424102354,%22chansub%22:{%22view_until%22:1924905600,%22restricted_bitrates%22:[]},%22private%22:{%22allowed_to_view%22:true},%22privileged%22:false,%22source_restricted%22:false}&sig=99c1c1135fca73337c32df80b0de446d40c60dfa'; window.open(encodeURIComponent(url),'Download');"; var host = window.location.host; if (host=="api.twitch.tv") { setTimeout(function(){ //console.log("loaded:" + GM_getValue("token")); var text = $("body").text(); console.log("text:" + text); var json = JSON.parse(text); console.log("json:" + json); var user = 'test'; var user = document.URL.split("api.twitch.tv/api/channels/")[1].split("/")[0]; var token = '{%22user_id%22:null,%22channel%22:%22scream%22,%22expires%22:1424102354,%22chansub%22:{%22view_until%22:1924905600,%22restricted_bitrates%22:[]},%22private%22:{%22allowed_to_view%22:true},%22privileged%22:false,%22source_restricted%22:false}'; var token = json['token']; var signature = '99c1c1135fca73337c32df80b0de446d40c60dfa'; var signature = json['sig']; var url = 'http://usher.justin.tv/api/channel/hls/' + user + '.m3u8?token=' + token + '&sig=' + signature; var urle = encodeURI(url); //window.open(url); $("body").html('<a href="' + urle + '">' + urle + '</a>"'); window.location.assign(url); //window.open(urle,"_blank"); setTimeout(function(){ window.close(); },1000) //localStorage.setItem("token", text); //GM_setValue("token", text); },1000) } else { var user = document.URL.split("twitch.tv/")[1].split("/")[0]; var tokenurl = 'http://api.twitch.tv/api/channels/' + user + '/access_token?grabber'; /* $.getJSON(tokenurl + '&callback=?', {}, function(data) { alert(data); } );*/ // Solution 1: $.ajax() and jsonp: /*$.ajax({ // type: "GET", // crossDomain: true, dataType: "jsonp", // jsonp url: 'http://api.twitch.tv/api/channels/scream/access_token', // data: data, // success: 1, }).done(function ( data ) { $.each(data, function(key, val) { console.log(key + ':' + val); }); });*/ /* $.ajax({ type: "POST", url: tokenurl, success: function(returntext) { alert(returntext); } }); */ setTimeout(function(){ var temp = document.querySelectorAll('.channel-actions')[0].innerHTML; document.querySelectorAll('.channel-actions')[0].innerHTML = temp + '<div class="action button"><a href="' + tokenurl + '" target="_blank">Grab stream link</a></div>'; },1000) }