您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Print content-type 'application/vnd.apple.mpegurl'
当前为
// ==UserScript== // @name Print requests with content-type 'application/vnd.apple.mpegurl' // @namespace http://your-domain-here/ // @version 6 // @description Print content-type 'application/vnd.apple.mpegurl' // @match http://*/* // @match https://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function logXHRRequest(method, url) { console.log('XHR request:', method, url); } function logXHRResponse(response) { const contentType = response.headers['content-type']; if (contentType === 'application/vnd.apple.mpegurl') { console.log('XHR response:', response.data); } } function addInterceptorToIframe(iframe) { const iframeWindow = iframe.contentWindow; const iframeDocument = iframe.contentDocument; // Attach the interceptor to the iframe's XMLHttpRequest object iframeWindow.XMLHttpRequest.prototype._send = iframeWindow.XMLHttpRequest.prototype.send; iframeWindow.XMLHttpRequest.prototype.send = function(data) { logXHRRequest(this.method, this.url); const _this = this; const xhrOverride = { set send(data) { _this._send.call(_this, data); }, set onreadystatechange(fn) { if (fn) { _this.addEventListener("readystatechange", function() { if (_this.readyState === 4) { logXHRResponse(_this); } fn.apply(null, arguments); }, false); } } }; for (const key in this) { if (this.hasOwnProperty(key)) { xhrOverride[key] = this[key]; } } this.xhrOverride = xhrOverride; this._send.call(this, data); }; // Attach the interceptor to fetch requests made in the iframe const originalFetch = iframeWindow.fetch; iframeWindow.fetch = function(url, options) { logXHRRequest('GET', url); return originalFetch.call(this, url, options).then(function(response) { if (response.headers.get('content-type') === 'application/vnd.apple.mpegurl') { response.clone().text().then(function(text) { console.log('XHR response:', text); }); } return response; }); }; // Attach the interceptor to the iframe's XMLHttpRequest object in the iframe's document const originalXHR = iframeDocument.defaultView.XMLHttpRequest; iframeDocument.defaultView.XMLHttpRequest = function() { const xhr = new originalXHR(); xhr.addEventListener('load', function() { logXHRResponse(xhr); }); return xhr; }; } // Get all iframes in the document and attach the interceptor to them const iframes = document.getElementsByTagName('iframe'); for (let i = 0; i < iframes.length; i++) { addInterceptorToIframe(iframes[i]); } })();