BLoxd.io Server Capture Console Logs

Captures console logs in a bloxd.io server and stores them in local storage.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         BLoxd.io Server Capture Console Logs
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Captures console logs in a bloxd.io server and stores them in local storage.
// @author       Nomu
// @match        https://bloxd.io/*
// @grant        none
// @icon         https://www.iconsdb.com/icons/preview/black/console-xxl.png
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Create an array to hold logs
    const logs = JSON.parse(localStorage.getItem('capturedLogs')) || [];

    // Override console.log to capture log messages
    const originalConsoleLog = console.log;

    console.log = function(...args) {
        // Create a timestamp
        const timestamp = new Date().toISOString();

        // Construct the log entry
        const logEntry = {
            timestamp: timestamp,
            message: args.join(' ')
        };

        // Push to logs array
        logs.push(logEntry);

        // Save to local storage
        localStorage.setItem('capturedLogs', JSON.stringify(logs));

        // Call the original console.log to maintain functionality
        originalConsoleLog.apply(console, args);
    };

    // Function to download logs as a file
    const downloadLogs = () => {
        const blob = new Blob([JSON.stringify(logs, null, 2)], { type: 'application/json' });
        const url = URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = 'capturedLogs.json';
        a.click();
        URL.revokeObjectURL(url);
    };

    // Add a button to download logs (you can style it as needed)
    const button = document.createElement('button');
    button.textContent = 'Download Logs';
    button.style.position = 'fixed';
    button.style.top = '10px';
    button.style.right = '10px';
    button.style.zIndex = '1000';
    button.onclick = downloadLogs;
    document.body.appendChild(button);

})();