CWSS

Complete WebSocket Sniffer

目前為 2022-01-16 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/438408/1009009/CWSS.js

作者
Exnonull
版本
1.1
建立日期
2022-01-12
更新日期
2022-01-16
尺寸
3.1 KB
授權條款
MIT

Example of Complete WebSocket Sniffer;
When page loaded: You can see all requests (from|to) server or any creation of WebSocket object in the devtools console;

usage:

    // priority => (event) -> Infinity .. -Infinity -> listener
    // "this" instance of "WebSocket" for all functions in "hook"
    hook {
      priority: Number,
      init?: Function(),
      send?: Function(data),
      open?: Function(event),
      message?: Function(event),
      close?: Function(event),
    }

    CWSS.sockets; // [WebSocket, WebSocket, ...];

    //returns CWSS
    CWSS.setHook(hook);
    CWSS.setHooks([hook, hook, ...] | hook, hook, ...);

example:

    CWSS.setHook({
      priority: 9,
      init() {
        console.log(`Open WebSocket channel by url: ${this.url}`, this);
        return arguments;
      },
      message(e) {
        console.log(`Got data:`, e.data);
        return arguments;
      },
      send(data) {
        console.log(`Sending data:`, data);
        return arguments;
      },
    });