// ==UserScript== // @name 广开自动评分助手(可拖动+缩小放大) // @namespace http://tampermonkey.net/ // @version 3.1 // @description 可拖动、可折叠缩小放大、全自动评分 // @author User // @match https://course.ougd.cn/* // @grant none // ==/UserScript== (function () { 'use strict'; // 禁止右键、复制、选中、查看源码快捷键 document.oncontextmenu = e => e.preventDefault(); document.onselectstart = e => e.preventDefault(); document.oncopy = e => e.preventDefault(); document.oncut = e => e.preventDefault(); document.onpaste = e => e.preventDefault(); document.onkeydown = function(e) { // 拦截F12、Ctrl+U、Ctrl+C、Ctrl+S if(e.keyCode === 123 || (e.ctrlKey && e.keyCode === 85) || (e.ctrlKey && e.keyCode === 67) || (e.ctrlKey && e.keyCode === 83)){ return false; } }; const USED_FLAG = "script_first_used"; let isFirstUse = !localStorage.getItem(USED_FLAG); let isRunning = false; let processedCount = 0; let isMinimized = false; const config = { minGrade: 98, maxGrade: 100, fillDelay: 300, submitDelay: 800, pageDelay: 1500, }; function getRandomGrade() { return Math.floor(Math.random() * (config.maxGrade - config.minGrade + 1)) + config.minGrade; } function setPerPage100() { return new Promise(resolve => { const sel = document.querySelector('select[onchange*="perpage"], select[name="perpage"]'); if (sel) { sel.value = "100"; sel.dispatchEvent(new Event("change")); setTimeout(resolve, 1000); } else { resolve(); } }); } function fillGrades() { const inputs = document.querySelectorAll('input.finalgrade'); if (!inputs.length) return 0; inputs.forEach(inp => { inp.value = getRandomGrade(); inp.dispatchEvent(new Event('input', {bubbles:true})); inp.dispatchEvent(new Event('change', {bubbles:true})); }); processedCount += inputs.length; updateInfo(); return inputs.length; } function submitPage() { return new Promise(resolve => { const btn = document.querySelector('input[value="提交成绩"].submit-btn'); if (btn) { btn.click(); setTimeout(resolve, config.submitDelay); } else { resolve(); } }); } function goNext() { return new Promise((resolve, reject) => { const lis = document.querySelectorAll('.pagination li'); let next = null; for (let li of lis) { if (li.classList.contains('disabled')) continue; let a = li.querySelector('a'); if (a && (a.textContent.includes('下一页') || a.textContent.includes('»'))) { next = a; break; } } if (next) { next.click(); setTimeout(()=>resolve(true), config.pageDelay); } else { reject("无下一页"); } }); } async function startAuto() { if (!isFirstUse) { alert("目前为试用版,如需体验完整版 联系qq3420232476"); return; } if (isRunning) return; localStorage.setItem(USED_FLAG, "1"); isRunning = true; updateBtnText(); processedCount = 0; await setPerPage100(); while (isRunning) { let cnt = fillGrades(); if (!cnt) break; await new Promise(r=>setTimeout(r, config.fillDelay)); await submitPage(); try { await goNext(); } catch (e) { alert("全部评分完成!"); break; } } isRunning = false; updateBtnText(); } function stopAuto() { isRunning = false; updateBtnText(); } function dragPanel(panel, head) { let x = 0, y = 0, downX = 0, downY = 0; head.onmousedown = function(e) { downX = e.clientX; downY = e.clientY; document.onmousemove = function(ev) { x = ev.clientX - downX; y = ev.clientY - downY; downX = ev.clientX; downY = ev.clientY; let t = parseInt(panel.style.top) || 20; let l = parseInt(panel.style.left) || window.innerWidth - 260; panel.style.top = (t + y) + "px"; panel.style.left = (l + x) + "px"; }; document.onmouseup = function() { document.onmousemove = null; document.onmouseup = null; }; }; } function toggleFold() { isMinimized = !isMinimized; const wrap = document.getElementById("panelWrap"); const body = document.getElementById("panelBody"); const btn = document.getElementById("foldBtn"); if (isMinimized) { body.style.display = "none"; wrap.style.width = "140px"; btn.innerText = "放大"; } else { body.style.display = "block"; wrap.style.width = "240px"; btn.innerText = "缩小"; } } function createUI() { if (document.getElementById("panelWrap")) return; const wrap = document.createElement("div"); wrap.id = "panelWrap"; wrap.style.cssText = ` position:fixed; top:20px; right:20px; width:240px; background:#fff; border:2px solid #007bff; border-radius:8px; z-index:999999; box-shadow:0 2px 10px #ccc; font-size:14px; `; const head = document.createElement("div"); head.style.cssText = ` background:#007bff; color:#fff; padding:6px 10px; display:flex; justify-content:space-between; align-items:center; border-radius:6px 6px 0 0; cursor:move; `; head.innerHTML = `评分助手`; const body = document.createElement("div"); body.id = "panelBody"; body.style.padding = "10px"; body.innerHTML = `
状态:已停止
已处理:0
`; wrap.appendChild(head); wrap.appendChild(body); document.body.appendChild(wrap); dragPanel(wrap, head); document.getElementById("foldBtn").onclick = toggleFold; document.getElementById("startBtn").onclick = startAuto; document.getElementById("stopBtn").onclick = stopAuto; } function updateBtnText() { const txt = document.getElementById("statTxt"); if (!txt) return; txt.innerHTML = isRunning ? '运行中' : '已停止'; } function updateInfo() { const el = document.getElementById("countTxt"); if (el) el.innerText = processedCount; } setTimeout(createUI, 800); })();