// ==UserScript== // @name b站开播助手 // @author 醒悦哥哥 // @description 绕过b站强制直播姬开播限制,修复OBS无法获取推流码的问题 // @version 1.0.1 // @match https://link.bilibili.com/p/center/index* // @grant none // @icon https://jujufatu.com/file/90dca92bc72742cc08214.png // ==/UserScript== (function() { 'use strict'; // 拦截XMLHttpRequest的open方法 const originalOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url) { // 检查是否是目标请求 if (method === 'POST' && url.includes('room/v1/Room/startLive')) { // 拦截send方法以修改请求参数 const originalSend = this.send; this.send = function(data) { // 将FormData转换为对象 const formData = new URLSearchParams(data); const formDataObj = Object.fromEntries(formData.entries()); // 修改platform参数 formDataObj['platform'] = 'mobile'; // 将对象转换回FormData const newFormData = new URLSearchParams(formDataObj).toString(); // 调用原始的send方法 originalSend.call(this, newFormData); }; } originalOpen.apply(this, arguments); }; })();