您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Предупреждает об опасности Информационной Безопасности
当前为
// ==UserScript== // @name Moodle PlusAlarm // @namespace https://t.me/johannmosin // @version 0.1.11 // @description Предупреждает об опасности Информационной Безопасности // @author Johann Mosin // @license MIT // @match https://*.edu.vsu.ru/html5client/* // @grant GM_setValue // @grant GM_getValue // @grant GM_openInTab // ==/UserScript== (function() { 'use strict'; const COOLDOWN = 120000; // 2 minutes in milliseconds const CHECK_INTERVAL = 5000; const TARGET_URL = 'https://zvukipro.com/uploads/files/2020-10/1602076786_8fa134cac873622.mp3'; // Change to your target URL let isCooldown = false; let lastUser = GM_getValue('lastUser', ''); let lastCheckedMessage = null; // To avoid processing the same last message repeatedly console.log('Script started. Last user:', lastUser); function getLatestMessage() { const messages = document.querySelectorAll('[data-test="msgListItem"]'); if (messages.length === 0) { console.log('No messages found in the chat.'); return null; } console.log('Total messages found:', messages.length); return messages[messages.length - 1]; } function extractMessageInfo(messageElement) { try { const userElement = messageElement.querySelector('.sc-gFkHhu span:first-child'); const textElement = messageElement.querySelector('[data-test="chatUserMessageText"]'); if (!userElement || !textElement) { console.log('Could not find user or text element in the message.'); return null; } const user = userElement.textContent.trim(); const text = textElement.textContent.trim(); console.log('Extracted message info:', { user, text }); return { user, text }; } catch (e) { console.error('Error extracting message info:', e); return null; } } function handleNewMessage() { const messageElement = getLatestMessage(); if (!messageElement) { console.log('No valid message element found.'); return; } // Check if this message is the same as the last checked message if (messageElement === lastCheckedMessage) { console.log('Same last message as last check. Skipping.'); return; } lastCheckedMessage = messageElement; // Update last checked message const messageInfo = extractMessageInfo(messageElement); if (!messageInfo) { console.log('No valid message info extracted.'); return; } if (messageInfo.text !== '+') { console.log('Message is not "+". Skipping.'); return; } if (messageInfo.user === lastUser) { console.log('Message is from the same user as last time. Skipping action, but still updating last user.'); } else { console.log('Message is from a new user:', messageInfo.user); } // Always update lastUser if it's a '+' message from a potentially new user if (messageInfo.user !== lastUser) { lastUser = messageInfo.user; GM_setValue('lastUser', lastUser); console.log('Updated last user:', lastUser); } if (isCooldown) { console.log('Cooldown active. Skipping action (opening tab).'); return; // Skip opening tab if cooldown is active } if (messageInfo.user === lastUser && messageInfo.user !== GM_getValue('lastUser', '')) { console.log('Message is from the same user but lastUser was updated in cooldown. Skipping action.'); return; // Skip opening tab if it is same user but lastUser was updated in cooldown } // Trigger action only if not in cooldown and it's a new user (or first time user) if (!isCooldown && messageInfo.user !== GM_getValue('lastUser', '') ) { // Changed condition to check against stored value to handle first run correctly console.log('Triggering action: Opening new tab for user:', messageInfo.user); GM_openInTab(TARGET_URL, { active: true }); // Start cooldown isCooldown = true; console.log('Cooldown started.'); setTimeout(() => { isCooldown = false; console.log('Cooldown ended.'); }, COOLDOWN); } else if (!isCooldown && messageInfo.user !== lastUser) { // Handle first time correctly console.log('Triggering action: Opening new tab for user (first time or after cooldown):', messageInfo.user); GM_openInTab(TARGET_URL, { active: true }); // Start cooldown isCooldown = true; console.log('Cooldown started.'); setTimeout(() => { isCooldown = false; console.log('Cooldown ended.'); }, COOLDOWN); } } function startChecking() { const chatContainer = document.querySelector('.ReactVirtualized__Grid__innerScrollContainer'); // Or the appropriate container selector if (!chatContainer) { console.log('Chat container not found yet. Waiting...'); setTimeout(startChecking, 1000); // Re-check in 1 second return; } console.log('Chat container found. Starting interval check.'); setInterval(handleNewMessage, CHECK_INTERVAL); } // Start checking for messages console.log('Waiting for chat container to load...'); startChecking(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址