您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Complete WebSocket Sniffer
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/438408/1041200/CWSS.js
// ==UserScript== // @license MIT // @name CWSS // @version 2.6 // @description Complete WebSocket Sniffer // @author 0vC4 // @match http://*/* // @match https://*/* // @grant none // @run-at document-start // @namespace https://greasyfork.org/users/670183 // ==/UserScript== const CWSS = (() => { const cwss = window.cwss || {}; if (cwss.ws) return cwss; const proto = WebSocket.prototype; const def = Object.defineProperty; const rebase = (obj, key, list) => def(obj, key, { configurable: true, enumerable: true, set: func => list.push(func) }); const native = (obj, value) => { obj.toString = function() { return Function.toString.call(value, ...arguments); }; }; const pipe = (type, ...next) => async function() { for (const hook of cwss.hooks.sort((a, b) => b.priority - a.priority)) { if (!hook[type]) continue; if (!arguments) break; arguments = await hook[type].call(this, ...arguments); } if (!arguments) return; next.flat().forEach(func => func.call(this, ...arguments)); }; const pipeSync = type => function() { for (const hook of cwss.hooks.sort((a, b) => b.priority - a.priority)) { if (!hook[type]) continue; if (!arguments) break; arguments = hook[type].call(this, ...arguments); } return arguments; }; cwss.ws = window.WebSocket; cwss.send = proto.send; cwss.addList = proto.addEventListener; cwss.sockets = []; cwss.hooks = []; cwss.setHook = hook => { cwss.hooks.push(hook); return cwss; }; cwss.setHooks = (...hooks) => { cwss.hooks.push(...hooks.flat()); return cwss; }; proto.send = pipe('send', cwss.send); proto.addEventListener = function() { const type = arguments[0]; const func = arguments[1]; const list = this.listeners[type]; if (list) list.push(func); else cwss.addList.call(this, ...arguments); }; window.WebSocket = function() { arguments = pipeSync('args').call(this, ...arguments); const ws = new cwss.ws(...arguments); for (const hook of cwss.hooks.sort((a, b) => b.priority - a.priority)) Object.assign(hook, { ws, async sendServer(data) { cwss.send.call(ws, data); }, async sendClient(data) { ws.listeners.message .forEach(func => func.call(ws, {data}) ); }, }); cwss.sockets.push(ws); pipe('init').call(ws); ws.listeners = {}; for (const key of ['open', 'message', 'close']) { const list = ws.listeners[key] = []; cwss.addList.call(ws, key, pipe(key, list)); rebase(ws, 'on'+key, list); } return ws; }; for (const k in cwss.ws) if (k != 'prototype') window.WebSocket[k] = cwss.ws[k]; for (const k in proto) if (k != 'constructor') try { window.WebSocket.prototype[k] = proto[k]; } catch (e) {}; native(proto.send, cwss.send); native(proto.addEventListener, cwss.addList); native(window.WebSocket, cwss.ws); window.cwss = cwss; return cwss; })(); // 0vC4#7152