您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Complete WebSocket Sniffer
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/438408/1030555/CWSS.js
// ==UserScript== // @license MIT // @name CWSS // @version 2.1 // @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 _hooks_ = 'hooks'; // all hooks WebSocket.prototype[_hooks_] const eventKey = key => key+'_listener'; // all event listeners WebSocket.prototype[eventKey('open'|'message'|'close')] const listeners = ['open', 'message', 'close']; // (+init&send hooks available by default) const proto = window.WebSocket.prototype; const def = Object.defineProperty; const hidden = (obj, key, value) => def(obj, key, {configurable: true, value}); 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 sockets = []; const hooks = (() => { if (_hooks_ in proto) return proto[_hooks_]; hidden(proto, _hooks_, []); const hooks = proto[_hooks_]; const {send, addEventListener} = proto; const pipe = (type, ...next) => async function() { for (const hook of hooks.sort((a, b) => b.priority - a.priority)) { if (hook[type]) arguments = await hook[type].call(this, ...arguments); if (!arguments) return; } next.flat().forEach(func => func.call(this, ...arguments)); }; const pipeSync = (type, ...next) => function() { for (const hook of hooks.sort((a, b) => b.priority - a.priority)) { if (hook[type]) arguments = hook[type].call(this, ...arguments); if (!arguments) return; } next.flat().forEach(func => func.call(this, ...arguments)); }; proto.send = pipe('send', send); native(proto.send, send); proto.addEventListener = function() { const type = arguments[0]; const func = arguments[1]; const list = this[eventKey(type)]; if (list) list.push(func); else addEventListener.call(this, ...arguments); } native(proto.addEventListener, addEventListener); const Ows = window.WebSocket; window.WebSocket = function() { arguments = pipeSync('args').call(arguments); const ws = new Ows(...arguments); sockets.push(ws); pipe('init').call(ws); for(const key of listeners) { const list_key = eventKey(key); const list = hidden(ws, list_key, [])[list_key]; addEventListener.call(ws, key, pipe(key, list)); rebase(ws, 'on'+key, list); } return ws; } for(const k in Ows) if (k != 'prototype') window.WebSocket[k] = Ows[k]; for(const k in Ows.prototype) if (k != 'constructor') try {window.WebSocket.prototype[k] = Ows.prototype[k];} catch(e) {}; WebSocket.prototype[_hooks_] = Ows.prototype[_hooks_]; native(window.WebSocket, Ows); window.WebSocket._send = send; return hooks; })(); const root = { sockets, setHook(hook) { hooks.push(hook); return root; }, setHooks(..._hooks) { hooks.push(..._hooks.flat()); return root; } }; return root; })(); // 0vC4#7152