// ==UserScript== // @name 📚 国开智能刷课助手 // @namespace http://tampermonkey.net/ // @version 2.2.5 // @description 国开自动刷课 - 云端授权版 智能反检测,q反馈群:612441267 // @author lakay666 // @match *://lms.ouchn.cn/course/* // @match *://lms.ouchn.cn/user/courses* // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @grant GM_registerMenuCommand // @grant GM_notification // @grant unsafeWindow // @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js // @run-at document-end // ==/UserScript== (function() { 'use strict'; const SERVER = 'http://150.158.119.55:3000'; const SK = 'gkbk_activation_code'; const mc = (() => { const gd = typeof unsafeWindow !== 'undefined' ? unsafeWindow.globalData : window.globalData; if (!gd || !gd.user || !gd.user.id) return null; let h = 0; const u = String(gd.user.userNo || gd.user.id); for (let i = 0; i < u.length; i++) { h = ((h << 5) - h) + u.charCodeAt(i); h |= 0; } return Math.abs(h).toString(16).toUpperCase(); })(); const un = (() => { const gd = typeof unsafeWindow !== 'undefined' ? unsafeWindow.globalData : window.globalData; return gd?.user?.name || '未知'; })(); function showLoading(msg) { let el = document.getElementById('gkbk-loading'); if (!el) { el = document.createElement('div'); el.id = 'gkbk-loading'; el.style.cssText = 'position:fixed;top:20px;right:20px;padding:12px 20px;background:#2d8cf0;color:#fff;border-radius:8px;z-index:2147483647;font-size:14px;box-shadow:0 4px 12px rgba(0,0,0,0.15);'; document.body.appendChild(el); } el.textContent = '📚 ' + msg; } function hideLoading() { const el = document.getElementById('gkbk-loading'); if (el) el.remove(); } function showAuthPanel() { if (document.querySelector('#gkbk-auth-panel')) return; const panel = document.createElement('div'); panel.id = 'gkbk-auth-panel'; panel.style.cssText = 'position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);width:360px;background:#fff;border-radius:16px;box-shadow:0 8px 32px rgba(0,0,0,0.2);z-index:2147483647;padding:24px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;'; panel.innerHTML = '

🔐 授权验证

'+ '
'+un+'
'+ '
'+ '
'+ '
'+ '
发给管理员获取激活码
'+ '
'+ '
'+ ''; document.body.appendChild(panel); document.getElementById('gkbk-copy').onclick = () => { GM_setClipboard(mc); showLoading('机器码已复制!'); setTimeout(hideLoading, 1500); }; document.getElementById('gkbk-verify').onclick = () => { const code = document.getElementById('gkbk-code').value.trim(); if (!code) { alert('请输入激活码!'); return; } GM_setValue(SK, code); panel.remove(); verifyAndLoad(code); }; } function decryptAES(enc, key, iv) { const k = CryptoJS.enc.Utf8.parse(key), i = CryptoJS.enc.Utf8.parse(iv); return CryptoJS.AES.decrypt(enc, k, { iv: i, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }).toString(CryptoJS.enc.Utf8); } function verifyAndLoad(activationCode) { showLoading('正在验证授权...'); GM_xmlhttpRequest({ method: 'POST', url: SERVER + '/api/verify', headers: { 'Content-Type': 'application/json' }, data: JSON.stringify({ machineCode: mc, activationCode: activationCode, userName: un, encrypt: false }), onload: function(r) { try { const res = JSON.parse(r.responseText); if (!res.success) { hideLoading(); alert('验证失败:' + res.message); GM_deleteValue(SK); showAuthPanel(); return; } showLoading('授权通过!正在加载核心功能...'); let script = res.coreScript; if (res.encrypted && res.decryptKey && res.decryptIv) { script = decryptAES(script, res.decryptKey, res.decryptIv); } if (!script) { hideLoading(); alert('核心脚本加载失败'); return; } eval(script); hideLoading(); const expireDate = new Date(res.expire); const daysLeft = Math.ceil((expireDate - Date.now()) / (1000 * 60 * 60 * 24)); if (daysLeft <= 7) { GM_notification({ title: '国开刷课助手', text: '激活码将在 ' + daysLeft + ' 天后到期,请及时续费', timeout: 10000 }); } } catch (e) { hideLoading(); alert('加载失败:' + e.message); console.error(e); } }, onerror: function() { hideLoading(); alert('无法连接服务器,请检查网络'); } }); } GM_registerMenuCommand('🔄 重置授权', () => { if (confirm('确定要重置授权吗?')) { GM_deleteValue(SK); location.reload(); } }); if (!mc) { alert('请在课程页面使用!'); return; } const savedCode = GM_getValue(SK, ''); if (savedCode) { verifyAndLoad(savedCode); } else { showAuthPanel(); } })();