Site Measurements

Logs fetch, xhr, ws requests in console

Stan na 05-08-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Site Measurements
// @namespace    http://tampermonkey.net/
// @version      2024-08-05
// @license      MIT
// @description  Logs fetch, xhr, ws requests in console
// @author       Grosmar
// @match        https://*.livejasmin.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=livejasmin.com
// @grant        none
// @run-at document-start
// ==/UserScript==

(function() {
    'use strict';
    console.log("MEASUREMENT");

    const filteredWs = /jaws\./;
    const binaryWsPackageCountLimit = 3; //show only this amount of binary packages
    const wsEventFilter = { r: /onRandomAccessPoint|onMetaData/, limit: 2} // messages with this content will be shown only `limit` amount of time



    const origFetch = fetch; window.fetch = (...args) => { console.warn("NETWORK_Fetch", ...args); return origFetch(...args); }
    const origOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function (...args) { console.warn("NETWORK_Xhr", ...args); return origOpen.apply(this, args); }
    const origWsSend = WebSocket.prototype.send; WebSocket.prototype.send = function(...args) { if (args[0] != 3 && !filteredWs.test(this.url)) console.warn("NETWORK_Ws_Send", ...args); return origWsSend.apply(this, args); }

    const OrigWs = window.WebSocket;
    window.WebSocket = function (url, protocols)
    {
        let ws = new OrigWs(url, protocols);
        if (!filteredWs.test(url)) {
            let binaryCount = 0;
            let filteredMsgCount = 0;
            console.warn("NETWORK_Ws_Conn", url, protocols);
            ws.addEventListener("message", (event) =>
                {
                    const isBinary = event.data instanceof ArrayBuffer;
                    const eventFilterTest = wsEventFilter.r.test(event.data);
                    if ((isBinary && binaryCount++ < binaryWsPackageCountLimit) || (!isBinary && (!eventFilterTest || filteredMsgCount++ < wsEventFilter.limit)))
                    {
                        console.warn("NETWORK_Ws_Msg", url, event);
                    }
                }
            );
        }
        return ws;
    }
})();