// ==UserScript== // @name 直播流获取 // @namespace mscststs // @version 0.3 // @description bilibili 获取直播流 // @author mscststs // @match https://live.bilibili.com/blanc/* // @match https://live.bilibili.com/* // @require https://cdn.bootcss.com/jquery/3.3.1/jquery.js // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; /** 工具库,拷贝 */ function msg(text,level,time,left,top){ text=text||"这是一个提示"; level=level||"success"; time=time||2000; if(level!="success"){ console.log(text); } var id = (new Date()).valueOf(); $("body").append(''); $("div.link-toast[data-id='"+id+"']").slideDown("normal",function(){setTimeout(function(){$("div.link-toast[data-id='"+id+"']").fadeOut("normal",function(){$("div.link-toast[data-id='"+id+"']").remove();});},time);}); } window.copy = window.copy || function (url) { const input = document.createElement('input'); input.setAttribute('value', url); input.setAttribute('readonly', 'readonly'); document.body.appendChild(input); input.select(); input.setSelectionRange(0, 99999999999); if (document.execCommand('copy')) { document.execCommand('copy'); console.log('复制成功',url); } document.body.removeChild(input); } let roomid = (()=>{ try{ let [[,roomid]] = [...window.location.pathname.matchAll(/\/(\d{1,})/g)] return roomid }catch(e){ return false; } })() console.log("roomid >>>>",roomid ) if(roomid){ (async ()=>{ $("body").append(` `) let {data:{play_url}} = await (await fetch(`https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomPlayInfo?room_id=${roomid}&play_url=1&mask=1&qn=4&platform=web`)).json() console.log(play_url.durl[0].url) $("div.right-container").prepend( `

直播流获取器

`) $("body").on("click",".stream_link",function(e){ var url = $(this).attr("data-url"); console.log("url",url,e) window.copy(url) msg("复制成功","success",2000,e.pageX+"px",e.pageY+"px") }); })() } // Your code here... })();