// ==UserScript== // @name 西农评教自动点击完全赞同 // @namespace https://newehall.nwafu.edu.cn/ // @version 1.0 // @description 一个开关,开启后自动检测并点击「完全赞同」按钮 // @author ji // @match https://newehall.nwafu.edu.cn/* // @grant none // @run-at document-idle // ==/UserScript== (function () { 'use strict'; // 配置:完全赞同的识别关键词(可按页面实际文本修改) const AGREE_KEYWORDS = ['完全赞同', '非常满意', '非常同意', '5分']; let isEnabled = false; // 开关状态 let checkInterval; // 检测定时器 // 1. 添加开关按钮 const addToggleSwitch = () => { // 开关样式(悬浮左下角,不遮挡) const style = ` #auto-agree-switch { position: fixed; bottom: 30px; left: 30px; z-index: 999999; padding: 12px 20px; border: none; border-radius: 20px; font-size: 14px; font-weight: bold; cursor: pointer; transition: all 0.2s; } .switch-off { background-color: #95a5a6; color: white; } .switch-on { background-color: #2ecc71; color: white; } `; document.head.insertAdjacentHTML('beforeend', ``); // 创建开关按钮 const switchBtn = document.createElement('button'); switchBtn.id = 'auto-agree-switch'; switchBtn.className = 'switch-off'; switchBtn.textContent = '开启自动点击完全赞同'; // 开关点击事件 switchBtn.addEventListener('click', toggleSwitch); document.body.appendChild(switchBtn); }; // 2. 开关切换逻辑 const toggleSwitch = () => { isEnabled = !isEnabled; const switchBtn = document.getElementById('auto-agree-switch'); if (isEnabled) { // 开启:启动检测定时器(每500ms检测一次新出现的按钮) switchBtn.className = 'switch-on'; switchBtn.textContent = '关闭自动点击'; checkInterval = setInterval(checkAndClickAgree, 500); // 立即执行一次 checkAndClickAgree(); } else { // 关闭:停止检测 switchBtn.className = 'switch-off'; switchBtn.textContent = '开启自动点击完全赞同'; clearInterval(checkInterval); } }; // 3. 核心逻辑:检测并点击完全赞同按钮 const checkAndClickAgree = () => { // 查找所有可能的单选选项(label或包含radio的容器) const options = document.querySelectorAll('label, .ant-radio-wrapper, .radio-option'); options.forEach(option => { const optText = option.textContent.trim(); // 匹配关键词 + 未选中 const isTarget = AGREE_KEYWORDS.some(key => optText.includes(key)); const radioInput = option.querySelector('input[type="radio"]'); if (isTarget && radioInput && !radioInput.checked) { option.click(); // 自动点击 } }); }; // 初始化:添加开关 window.addEventListener('load', addToggleSwitch); })();