Drawaria Advanced Moderation (English)

Helps host auto-detect offensive words, AFK players, and trolls in Drawaria

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Drawaria Advanced Moderation (English)
// @namespace    https://greasyfork.org
// @version      1.0
// @description  Helps host auto-detect offensive words, AFK players, and trolls in Drawaria
// @match        *://drawaria.online/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const bannedWords = ["badword1", "badword2", "spam", "idiot"]; // Add more if needed
    const afkTime = 90000; // 90 seconds of no activity

    let players = {}; // Track player activity

    // Observe chat for banned words
    const chatObserver = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            mutation.addedNodes.forEach((node) => {
                if (node.nodeType === Node.ELEMENT_NODE) {
                    const message = node.textContent.toLowerCase();
                    const name = node.querySelector("b")?.textContent || "Unknown";

                    for (let word of bannedWords) {
                        if (message.includes(word)) {
                            node.style.background = "red";
                            node.style.color = "white";
                            alert(`⚠️ Player ${name} used a banned word:\n"${message}"`);
                        }
                    }

                    // Update player activity
                    if (!players[name]) players[name] = {};
                    players[name].lastMessage = Date.now();
                }
            });
        });
    });

    // Detect AFK players
    setInterval(() => {
        const now = Date.now();
        for (let name in players) {
            const last = players[name].lastMessage || 0;
            if (now - last > afkTime) {
                console.warn(`Player ${name} might be AFK.`);
                alert(`🕒 Player ${name} has been inactive for more than ${afkTime / 1000} seconds.`);
                players[name].lastMessage = now; // Reset timer to prevent repeat alerts
            }
        }
    }, 30000); // Check every 30 seconds

    // Simple troll detection (no drawing)
    const canvas = document.querySelector("canvas");
    if (canvas) {
        const ctx = canvas.getContext("2d");
        let previousImage = ctx.getImageData(0, 0, canvas.width, canvas.height).data;

        setInterval(() => {
            const currentImage = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
            let changes = 0;

            for (let i = 0; i < currentImage.length; i += 4) {
                if (currentImage[i] !== previousImage[i]) {
                    changes++;
                }
            }

            if (changes < 1000) { // Minimal drawing
                console.warn("👻 Possible troll: very little drawing detected.");
                alert("🎨 Warning: the current drawer may be trolling (very minimal drawing).");
            }

            previousImage = currentImage;
        }, 15000); // Check every 15 seconds
    }

    // Start chat observer
    const chat = document.querySelector(".chat-box") || document.querySelector(".chat");
    if (chat) {
        chatObserver.observe(chat, { childList: true, subtree: true });
    }
})();