Swordz.io Clean Layout

Cleans up Swordz.io and adds a spam bot (more versions to come)

当前为 2025-02-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Swordz.io Clean Layout
// @namespace    intuxs
// @version      1.0
// @description  Cleans up Swordz.io and adds a spam bot (more versions to come)
// @author       YourName
// @match        *.swordz.io
// @grant        none
// ==/UserScript==

// ==========================================
// Collapsible UI
// ==========================================

const uiContainer = document.createElement('div');
uiContainer.style.position = 'fixed';
uiContainer.style.top = '10px';
uiContainer.style.left = '10px';
uiContainer.style.zIndex = '9999';
uiContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
uiContainer.style.padding = '10px';
uiContainer.style.borderRadius = '10px';
uiContainer.style.color = '#fff';
uiContainer.style.fontFamily = 'Arial, sans-serif';
document.body.appendChild(uiContainer);

// Collapse/Expand Button
const collapseButton = document.createElement('button');
collapseButton.textContent = '[-]';
collapseButton.style.marginBottom = '10px';
collapseButton.style.cursor = 'pointer';
collapseButton.addEventListener('click', () => {
    uiContainer.style.width = uiContainer.style.width === '200px' ? 'auto' : '200px';
    collapseButton.textContent = uiContainer.style.width === '200px' ? '[-]' : '[+]';
});
uiContainer.appendChild(collapseButton);

// ==========================================
// AI Spam Bot Functionality
// ==========================================

var spam = false; // Toggle spam on/off
var spamMessage = "Subscribe to DeepSeek AI!"; // Default spam message

// Create a UI element for the AI Spam Bot
const botLabel = document.createElement('div');
botLabel.textContent = 'Ai Spam Bot [P]';
botLabel.style.color = 'orange';
botLabel.style.fontSize = '16px';
botLabel.style.fontWeight = 'bold';
botLabel.style.textShadow = '2px 2px 4px #000';
uiContainer.appendChild(botLabel);

// Create an input field for custom spam messages
const input = document.createElement('input');
input.style.width = '100%';
input.style.marginTop = '10px';
input.style.height = '25px';
input.style.borderRadius = '5px';
input.style.backgroundColor = '#222';
input.style.color = '#fff';
input.style.border = '1px solid #555';
input.style.padding = '5px';
input.placeholder = 'Enter spam message';
uiContainer.appendChild(input);

// Function to send spam messages
function spamChat() {
    if (spam) {
        const message = input.value.trim() !== '' ? input.value : spamMessage; // Use custom message or default
        console.log('Sending message:', message);

        // Debugging: Check if the chat message is sent
        try {
            socket.emit('keyPressX', {
                inputId: 'chatMessage',
                state: message
            });
            console.log('Message sent successfully!');
        } catch (error) {
            console.error('Error sending message:', error);
        }
    }
}

// Toggle spam on/off with the 'P' key
document.addEventListener('keydown', function (e) {
    if (e.keyCode === 80) { // 'P' key to toggle spam
        spam = !spam;
        botLabel.textContent = `Ai Spam Bot [P] ${spam ? 'ON' : 'OFF'}`;
        botLabel.style.color = spam ? 'lime' : 'orange'; // Change color when toggled
        console.log(`Spam ${spam ? 'enabled' : 'disabled'}`);
    }
});

// Continuously send spam messages
setInterval(spamChat, 1000); // Adjust the interval (in milliseconds) as needed

// ==========================================
// Cleaner Swordz [O] Functionality
// ==========================================

var cleanerMode = false; // Toggle cleaner mode on/off

// Create a UI element for Cleaner Swordz
const cleanerLabel = document.createElement('div');
cleanerLabel.textContent = 'Cleaner Swordz [O]';
cleanerLabel.style.color = 'orange';
cleanerLabel.style.fontSize = '16px';
cleanerLabel.style.fontWeight = 'bold';
cleanerLabel.style.textShadow = '2px 2px 4px #000';
cleanerLabel.style.marginTop = '10px';
uiContainer.appendChild(cleanerLabel);

// Function to toggle cleaner mode
function toggleCleanerMode() {
    cleanerMode = !cleanerMode;
    cleanerLabel.textContent = `Cleaner Swordz [O] ${cleanerMode ? 'ON' : 'OFF'}`;
    cleanerLabel.style.color = cleanerMode ? 'lime' : 'orange';

    // Hide/show YouTube wrapper
    const youtubeWrapper = document.getElementById('youtubeWrapper');
    if (youtubeWrapper) {
        youtubeWrapper.style.display = cleanerMode ? 'none' : 'block';
    }

    // Resize sword logo
    const logo = document.querySelector('img[src="https://playem.io/cache/swordzio/client/img/logo.png"]');
    if (logo) {
        logo.style.width = cleanerMode ? '120px' : '240px'; // Smaller size when cleaner mode is on
        logo.style.height = cleanerMode ? '30px' : '60px';
    }

    // Hide black boxes
    hideBlackBoxes(cleanerMode);
}

// Toggle cleaner mode on/off with the 'O' key
document.addEventListener('keydown', function (e) {
    if (e.keyCode === 79) { // 'O' key to toggle cleaner mode
        toggleCleanerMode();
    }
});

// Function to hide black boxes
function hideBlackBoxes(hide) {
    const screenWidth = window.innerWidth;
    const screenHeight = window.innerHeight;
    const targetArea = {
        x1: 0, // Left edge
        x2: screenWidth / 2, // Middle of the screen
        y1: screenHeight / 2, // Middle of the screen
        y2: screenHeight // Bottom edge
    };

    const allElements = document.querySelectorAll('*');
    allElements.forEach(element => {
        const rect = element.getBoundingClientRect();
        const isInArea = (
            rect.left >= targetArea.x1 &&
            rect.right <= targetArea.x2 &&
            rect.top >= targetArea.y1 &&
            rect.bottom <= targetArea.y2
        );

        if (isInArea && hide) {
            element.style.display = 'none';
        } else if (isInArea && !hide) {
            element.style.display = 'block';
        }
    });
}