// ==UserScript== // @name 【效率版】广西学法用法考试答题助手 // @namespace https://card.wlxy.live/details/EBE2B74A // @version 1.0 // @description 广西普法网考(gxpf.sft.gxzf.gov.cn)答题助手,30秒搞定考试,请在「我的考试」列表页运行脚本。 // @icon https://huaweicloudobs.ahjxjy.cn/895789f9086469785b846d30c0ed95f9.png // @match *://gxpf.sft.gxzf.gov.cn/* // @connect oa51.ahzsksw.cn // @connect *.ahzsksw.cn // @connect card.wlxy.live // @connect huaweicloudobs.ahjxjy.cn // @grant GM_xmlhttpRequest // @grant GM.xmlHttpRequest // @grant GM_getValue // @grant GM_setValue // @grant unsafeWindow // @author 柠檬真酸 // @antifeature payment 需购买 Pro Token // @antifeature membership 仅 Pro 可用 // @tag 广西普法 // @tag 学法用法 // @tag 自动答题 // @license All Rights Reserved // @run-at document-idle // ==/UserScript== (() => { 'use strict'; const STORE = { token: 'gxpf_cloud_token_v1', lease: 'gxpf_cloud_lease_v1', account: 'gxpf_account_id_v1', accountName: 'gxpf_account_name_v1', autoSubmit: 'gxpf_auto_submit_v1', uiFill: 'gxpf_ui_fill_v1', }; const DEFAULT_BASE = 'https://oa51.ahzsksw.cn'; const SCRIPT_ICON = 'https://huaweicloudobs.ahjxjy.cn/895789f9086469785b846d30c0ed95f9.png'; const PRO_BUY_URL = 'https://card.wlxy.live/details/EBE2B74A'; const DEFAULT_PANEL_NOTICE = '\u5e7f\u897f\u5b66\u6cd5\u7528\u6cd5\u8003\u8bd5\u52a9\u624b'; const PANEL_TAGS = ['\u81ea\u52a8\u7b54\u9898', '\u4e00\u952e\u5b8c\u6210']; const CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e'; const API_ORIGIN = 'https://gxpf.sft.gxzf.gov.cn'; const SCRIPT_VERSION = '1.0'; const PASS_SCORE = 60; const LIST_PAGE_PATH = '/portal/exam/wdks/index'; const LIST_PAGE_URL = `${API_ORIGIN}${LIST_PAGE_PATH}`; const LIST_PAGE_HINT = '\u8bf7\u56de\u5230\u300c\u6211\u7684\u8003\u8bd5\u300d\u5217\u8868\u9875\u518d\u5f00\u59cb\uff08\u52ff\u5728\u7b54\u9898\u9875\u8fd0\u884c\uff09'; const gmGet = (key, fallback) => { try { if (typeof GM_getValue === 'function') return GM_getValue(key, fallback); } catch {} try { const raw = localStorage.getItem(key); return raw == null ? fallback : JSON.parse(raw); } catch { return fallback; } }; const gmSet = (key, value) => { try { if (typeof GM_setValue === 'function') return GM_setValue(key, value); } catch {} try { localStorage.setItem(key, JSON.stringify(value)); } catch {} }; const gmGetStr = (key, fallback = '') => { const v = gmGet(key, fallback); return typeof v === 'string' ? v : (v == null ? fallback : String(v)); }; const state = { baseUrl: DEFAULT_BASE, cloudToken: gmGetStr(STORE.token, ''), cloudLease: '', cloudLeaseExp: 0, cloudLeaseLuid: '', cloudTier: 'unknown', proExpiresText: '', proExpiresAt: 0, panelNotice: DEFAULT_PANEL_NOTICE, proBuyUrl: PRO_BUY_URL, running: false, stop: false, done: 0, matched: 0, missed: 0, total: 0, message: '\u5f85\u547d', accountId: '', accountName: '', logs: [], projectName: '', examName: '', scoreText: '-', scoreNum: NaN, delayMs: 280, autoSubmit: true, uiFill: false, examId: '', paperId: '', }; gmSet(STORE.autoSubmit, true); gmSet(STORE.uiFill, false); const sleep = ms => new Promise(r => setTimeout(r, ms)); const escHtml = text => String(text || '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', }[c])); function gmXhr(details) { const xhr = (typeof GM_xmlhttpRequest === 'function' && GM_xmlhttpRequest) || (typeof GM !== 'undefined' && typeof GM.xmlHttpRequest === 'function' && GM.xmlHttpRequest); if (!xhr) return Promise.reject(new Error('\u5f53\u524d\u6269\u5c55\u4e0d\u652f\u6301\u8de8\u57df\u8bf7\u6c42')); return new Promise((resolve, reject) => { let settled = false; const done = (fn, value) => { if (!settled) { settled = true; fn(value); } }; try { const ret = xhr({ ...details, onload: response => done(resolve, response), onerror: err => done(reject, new Error((err && err.error) || '\u7f51\u7edc\u8fde\u63a5\u5931\u8d25')), ontimeout: () => done(reject, new Error('\u8bf7\u6c42\u8d85\u65f6')), onabort: () => done(reject, new Error('\u8bf7\u6c42\u5df2\u53d6\u6d88')), }); if (ret && typeof ret.then === 'function') { ret.then(r => done(resolve, r), e => done(reject, e instanceof Error ? e : new Error(String(e)))); } } catch (error) { done(reject, error instanceof Error ? error : new Error(String(error))); } }); } function pushLog(text) { const line = `${new Date().toLocaleTimeString()} ${text}`; state.logs.unshift(line); if (state.logs.length > 80) state.logs.length = 80; } function cookieGet(name) { const m = document.cookie.match(new RegExp(`(?:^|;\\s*)${name.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')}=([^;]*)`)); return m ? decodeURIComponent(m[1]) : ''; } function readJsonCookie(name) { const raw = cookieGet(name); if (!raw) return null; try { return JSON.parse(raw); } catch {} try { return JSON.parse(decodeURIComponent(raw)); } catch {} return null; } function getExamToken() { return cookieGet('Exam-Token') || (localStorage.getItem('Exam-Token') || '').replace(/^"|"$/g, '') || ''; } function getUserInfo() { const fromCookie = readJsonCookie('USER_INFO'); if (fromCookie && typeof fromCookie === 'object') return fromCookie; try { const raw = localStorage.getItem('USER_INFO') || localStorage.getItem('userInfo'); if (raw) return JSON.parse(raw); } catch {} return null; } function normalizeIdNumber(value) { return String(value || '').trim().toUpperCase().replace(/\s+/g, ''); } function saveAccount(idnumber, name = '') { const id = normalizeIdNumber(idnumber); if (!id || id.length < 4) return ''; gmSet(STORE.account, id); if (name) gmSet(STORE.accountName, String(name).trim()); state.accountId = id; if (name) state.accountName = String(name).trim(); return id; } function syncAccountFromPlatform() { const user = getUserInfo(); if (!user) return ''; const id = normalizeIdNumber(user.identityCard || user.userId || ''); const name = String(user.nickName || user.userName || '').trim(); if (id) saveAccount(id, name); else if (name) state.accountName = name; return currentUserId(); } function currentUserId() { let id = normalizeIdNumber(gmGetStr(STORE.account, '') || state.accountId || ''); const user = getUserInfo(); if (user) { const uid = normalizeIdNumber(user.identityCard || user.userId || ''); const uname = String(user.nickName || user.userName || '').trim(); if (uid) { saveAccount(uid, uname || state.accountName); id = uid; } else if (uname) state.accountName = uname; } if (id.length >= 15) return `idcard:${id}`; if (id) return `uid:${id}`; return ''; } function accountLabel() { const name = String(state.accountName || '').trim(); if (name) return name; if (!currentUserId()) return '\u672a\u8bc6\u522b\u8d26\u53f7'; return '\u5df2\u7ed1\u5b9a\uff08\u672a\u8bc6\u522b\u59d3\u540d\uff09'; } function formatProExpireText(ts, fallback = '') { const n = Number(ts); if (Number.isFinite(n) && n > 1000) { try { return new Date(n * 1000).toLocaleString('sv-SE', { timeZone: 'Asia/Shanghai' }).replace('T', ' '); } catch {} } return String(fallback || '').trim(); } async function _crq(path, method = 'GET', payload) { const headers = { Accept: 'application/json' }; const luid = currentUserId(); if (luid) headers['x-learning-user-id'] = luid; if (state.cloudToken) headers.Authorization = `Bearer ${state.cloudToken}`; const opts = { url: `${String(state.baseUrl || '').replace(/\/+$/, '')}${path}`, method, timeout: 120000, headers, }; if (method !== 'GET') { headers['Content-Type'] = 'application/json'; const body = Object.assign({}, payload || {}); if (path !== '/api/gxpf/lease' && state.cloudLease && body.lease == null) body.lease = state.cloudLease; if (body.learning_user_id == null) body.learning_user_id = luid; opts.data = JSON.stringify(body); } const response = await gmXhr(opts); let wire = null; try { wire = JSON.parse(response.responseText || '{}'); } catch { wire = null; } if (!response.status) throw new Error('\u670d\u52a1\u65e0\u54cd\u5e94'); if (response.status === 401 || response.status === 403) { const msg = (wire && (wire.message || wire.detail)) || `HTTP ${response.status}`; const err = new Error(msg); err.status = response.status; err.wire = wire; throw err; } if (!wire || wire.ok === false) { throw new Error((wire && (wire.message || wire.detail)) || `\u8bf7\u6c42\u5931\u8d25 HTTP ${response.status}`); } return wire; } function _rlc() { const cached = gmGet(STORE.lease, null); if (!cached || typeof cached !== 'object') return; const luid = currentUserId(); if (cached.luid && luid && cached.luid !== luid) return; state.cloudLease = cached.lease || ''; state.cloudLeaseExp = Number(cached.exp || 0); state.cloudLeaseLuid = cached.luid || ''; state.cloudTier = cached.tier || state.cloudTier; state.proExpiresAt = Number(cached.proExpiresAt || 0) || 0; state.proExpiresText = formatProExpireText(state.proExpiresAt, cached.proExpiresText || ''); } function _slc() { gmSet(STORE.lease, { lease: state.cloudLease, exp: state.cloudLeaseExp, luid: state.cloudLeaseLuid, tier: state.cloudTier, proExpiresAt: state.proExpiresAt, proExpiresText: state.proExpiresText, }); } function _aqw(wire) { if (!wire || typeof wire !== 'object') return; if (wire.tier) state.cloudTier = String(wire.tier).toLowerCase(); if (wire.pro_expires_at != null) { state.proExpiresAt = Number(wire.pro_expires_at || 0) || 0; state.proExpiresText = formatProExpireText(state.proExpiresAt, wire.pro_expires_at_text || ''); } _slc(); } function _afm(msg) { const m = String(msg || ''); if (/pro_required/i.test(m)) return '\u9700\u5f00\u901a Pro \u5e76\u586b\u5199 Token \u540e\u65b9\u53ef\u4f7f\u7528'; if (/token_bound|learning_user_mismatch/i.test(m)) return 'Token \u5df2\u7ed1\u5b9a\u5176\u4ed6\u8d26\u53f7\uff0c\u8bf7\u6362\u65b0\u5361\u6216\u540e\u53f0\u5220\u9664\u65e7\u7ed1\u5b9a\u540e\u518d\u6821\u9a8c'; if (/revoked/i.test(m)) return 'Token \u5df2\u88ab\u540e\u53f0\u7981\u7528'; if (/invalid token/i.test(m)) return 'Token \u65e0\u6548'; if (/expired/i.test(m)) return 'Token \u5df2\u8fc7\u671f'; if (/invalid_lease/i.test(m)) return '\u6388\u6743\u5df2\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u6821\u9a8c'; if (/missing Authorization/i.test(m)) return '\u8bf7\u5148\u586b\u5199 Pro Token'; return m || '\u6388\u6743\u5931\u8d25'; } async function _cvt() { if (!state.cloudToken) return false; try { await _crq('/api/license/verify', 'GET'); return true; } catch (error) { const msg = error.message || ''; if (/revoked|invalid token|expired/i.test(msg)) state.cloudTier = 'revoked'; else if (/token_bound|learning_user_mismatch/i.test(msg)) state.cloudTier = 'bound'; state.message = _afm(msg); render(); return false; } } async function _ecl(forceRefresh = false) { const luid = currentUserId(); if (!luid) { state.message = '\u672a\u8bc6\u522b\u767b\u5f55\u8d26\u53f7\uff1a\u8bf7\u5148\u767b\u5f55\u5e7f\u897f\u666e\u6cd5\u5e73\u53f0'; render(); return false; } if (state.cloudLeaseLuid && state.cloudLeaseLuid !== luid) { state.cloudLease = ''; state.cloudLeaseExp = 0; state.cloudTier = 'unknown'; } const now = Math.floor(Date.now() / 1000); if (!forceRefresh && state.cloudLease && state.cloudLeaseLuid === luid && state.cloudLeaseExp - now > 60) { return true; } try { const data = await _crq('/api/gxpf/lease', 'POST', { learning_user_id: luid, name: state.accountName || '', userName: state.accountId || '', }); state.cloudLease = data.lease || ''; state.cloudLeaseExp = Number(data.exp || 0); state.cloudLeaseLuid = luid; state.cloudTier = String(data.tier || 'pro').toLowerCase(); state.proExpiresAt = Number(data.pro_expires_at || 0) || 0; state.proExpiresText = formatProExpireText(state.proExpiresAt, data.pro_expires_at_text || ''); _slc(); return state.cloudTier === 'pro'; } catch (error) { const msg = error.message || ''; if (/revoked|invalid token|expired/i.test(msg)) state.cloudTier = 'revoked'; else if (/token_bound|learning_user_mismatch/i.test(msg)) state.cloudTier = 'bound'; else if (/pro_required|missing Authorization/i.test(msg)) state.cloudTier = 'unknown'; state.message = `\u6388\u6743\u5931\u8d25\uff1a${_afm(msg)}`; render(); return false; } } async function _ecr() { _rlc(); syncAccountFromPlatform(); if (state.cloudTier === 'revoked' || state.cloudTier === 'bound') { state.cloudLease = ''; state.cloudLeaseExp = 0; state.cloudTier = 'unknown'; } if (!currentUserId()) { state.message = '\u672a\u8bc6\u522b\u767b\u5f55\u8d26\u53f7\uff1a\u8bf7\u5148\u767b\u5f55\u8003\u751f\u8d26\u53f7'; render(); return false; } if (!getExamToken()) { state.message = '\u672a\u627e\u5230 Exam-Token\uff0c\u8bf7\u91cd\u65b0\u767b\u5f55\u5e73\u53f0'; render(); return false; } if (!String(state.cloudToken || '').trim()) { state.message = '\u9700\u5f00\u901a Pro\uff1a\u8bf7\u586b\u5199 Token \u540e\u4fdd\u5b58\u6821\u9a8c'; render(); return false; } const verified = await _cvt(); if (!verified) { render(); return false; } const ok = await _ecl(true); if (!ok) return false; if (state.cloudTier !== 'pro') { state.message = '\u9700\u5f00\u901a Pro \u540e\u65b9\u53ef\u4f7f\u7528'; render(); return false; } return true; } function _opb() { const url = String(state.proBuyUrl || PRO_BUY_URL).trim() || PRO_BUY_URL; try { window.open(url, '_blank', 'noopener,noreferrer'); } catch {} } function parseQuery() { const q = new URLSearchParams(location.search || ''); return { examId: q.get('examId') || '', paperId: q.get('paperId') || '', examName: q.get('examName') || '', num: q.get('num') || '', }; } function isExamPage() { return /\/portal\/exam\/wdks\/details/i.test(location.pathname) || !!document.querySelector('.question-area, .answer-sheet, .question-number'); } function isExamListPage() { return /\/portal\/exam\/wdks\/index/i.test(location.pathname) || /\/portal\/exam\/home/i.test(location.pathname); } async function _pf(path, method = 'GET', body) { const token = getExamToken(); if (!token) throw new Error('\u672a\u767b\u5f55\u6216\u767b\u5f55\u5df2\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u767b\u5f55'); const headers = { Accept: 'application/json, text/plain, */*', Authorization: `Bearer ${token}`, Clientid: CLIENT_ID, }; const opts = { url: `${API_ORIGIN}/api${path}`, method, timeout: 60000, headers, }; if (method !== 'GET') { headers['Content-Type'] = 'application/json'; opts.data = typeof body === 'string' ? body : JSON.stringify(body || {}); } const response = await gmXhr(opts); let wire = null; try { wire = JSON.parse(response.responseText || '{}'); } catch { wire = null; } if (!response.status || response.status >= 400) { throw new Error((wire && (wire.msg || wire.message)) || `\u8bf7\u6c42\u5931\u8d25 ${response.status || 0}`); } if (!wire || (wire.code != null && Number(wire.code) !== 200)) { throw new Error((wire && (wire.msg || wire.message)) || '\u8bf7\u6c42\u5931\u8d25'); } return wire; } function _fst(score) { if (score == null || score === '') return '-'; if (!Number.isFinite(Number(score))) return '-'; const raw = String(score).trim(); if (/^\d+(\.\d+)?$/.test(raw)) return `${raw}\u5206`; return `${Number(score)}\u5206`; } function _ner(row) { const info = row && row.examInfo ? row.examInfo : {}; const examId = String(info.id || (row && row.examId) || '').trim(); const paperId = String(info.paperId || '').trim(); const examName = String(info.examName || (row && row.examName) || '').trim(); const scoreRaw = row && row.score != null && row.score !== '' ? row.score : null; const score = scoreRaw == null ? NaN : Number(scoreRaw); const passed = String((row && row.isPassed) || '') === '1' || (Number.isFinite(score) && score >= PASS_SCORE); const statusOk = String(info.status || '1') === '1'; const startTs = Date.parse(info.startTime || '') || 0; const endTs = Date.parse(info.endTime || '') || 0; const now = Date.now(); const inWindow = (!startTs || now >= startTs) && (!endTs || now <= endTs); const year = Number((examName.match(/(20\d{2})/) || [])[1] || 0); return { examId, paperId, examName, score, scoreText: _fst(scoreRaw == null ? score : scoreRaw), passed, statusOk, inWindow, year, num: '', }; } function _pce(rows) { const scored = (Array.isArray(rows) ? rows : []) .map(_ner) .filter(x => x.examId); if (!scored.length) return null; scored.sort((a, b) => { const aCur = (a.statusOk && a.inWindow) ? 1 : 0; const bCur = (b.statusOk && b.inWindow) ? 1 : 0; if (bCur !== aCur) return bCur - aCur; const aTodo = (a.statusOk && a.inWindow && !a.passed) ? 1 : 0; const bTodo = (b.statusOk && b.inWindow && !b.passed) ? 1 : 0; if (bTodo !== aTodo) return bTodo - aTodo; return b.year - a.year; }); return scored[0] || null; } function _aeh(hit) { if (!hit || !hit.examId) return; state.examId = String(hit.examId); if (hit.paperId) state.paperId = String(hit.paperId); if (hit.examName) { state.examName = hit.examName; state.projectName = hit.examName; } if (Number.isFinite(hit.score)) { state.scoreNum = hit.score; state.scoreText = hit.scoreText || _fst(hit.score); } else if (hit.scoreText && hit.scoreText !== '-') { state.scoreText = hit.scoreText; } } async function _fel() { const wire = await _pf('/exam/api/v1/exam/list', 'GET'); return Array.isArray(wire.data) ? wire.data : []; } async function _rch() { try { const cfg = await _pf('/system/config/getConfig?key=sys.exam.user.add', 'GET'); const raw = String(cfg.data || '').trim(); const parts = raw.split(',').map(s => s.trim()).filter(Boolean); if (!parts.length) return null; const last = parts[parts.length - 1] || ''; const opened = /\u5f00\u542f|\u5f00|1|true/i.test(last); if (parts.length >= 2 && /^\d+$/.test(parts[0]) && (opened || parts.length === 2)) { return { examId: parts[0], examName: opened ? (parts.slice(1, -1).join(',') || parts[1] || '') : (parts.slice(1).join(',') || ''), }; } if (/^\d+$/.test(parts[0])) { return { examId: parts[0], examName: parts[1] || '' }; } } catch {} return null; } async function _rae() { const q = parseQuery(); let preferredId = q.examId || ''; let preferredName = ''; if (q.examName) { try { preferredName = decodeURIComponent(q.examName); } catch { preferredName = q.examName; } } if (!preferredId) { const hint = await _rch(); if (hint && hint.examId) { preferredId = hint.examId; preferredName = hint.examName || preferredName; } } let rows = []; try { rows = await _fel(); } catch {} if (preferredId && rows.length) { const hit = rows.map(_ner).find(x => x.examId === String(preferredId)); if (hit) { if (q.paperId) hit.paperId = q.paperId; if (preferredName && !hit.examName) hit.examName = preferredName; hit.num = q.num || ''; return hit; } } if (preferredId) { return { examId: preferredId, paperId: q.paperId || '', examName: preferredName, score: NaN, scoreText: '-', passed: false, statusOk: true, inWindow: true, year: 0, num: q.num || '', }; } return _pce(rows); } async function _ses(silent) { if (!getExamToken()) return null; try { const hit = await _rae(); if (!hit) return null; _aeh(hit); if (!silent) { if (isExamFinished()) { state.message = `\u672c\u9879\u76ee\u5df2\u5408\u683c\uff08${state.scoreText}\uff09\uff0c\u65e0\u9700\u518d\u7b54`; } else if (!state.running && isExamListPage()) { state.message = '\u5df2\u8bc6\u522b\u5f53\u524d\u8003\u8bd5\uff0c\u53ef\u76f4\u63a5\u5f00\u59cb'; } } return hit; } catch (error) { if (!silent) { state.message = `\u8bfb\u53d6\u8003\u8bd5\u4fe1\u606f\u5931\u8d25\uff1a${error.message || error}`; } return null; } } async function _rcx() { if (state.running) return; if (isExamPage()) { state.message = LIST_PAGE_HINT; pushLog(state.message); render(); return; } if (!isExamListPage()) { state.message = '\u8bf7\u6253\u5f00\u300c\u6211\u7684\u8003\u8bd5\u300d\u5217\u8868\u9875\u540e\u518d\u5f00\u59cb'; pushLog(state.message); render(); return; } const q = parseQuery(); if (isExamFinished() && state.examId && q.examId && q.examId === state.examId) { state.message = `\u5df2\u5b8c\u6210\uff08\u5f97\u5206 ${state.scoreText} ≥ ${PASS_SCORE}\uff09\uff0c\u65e0\u9700\u518d\u7b54`; pushLog(state.message); render(); return; } state.message = '\u6b63\u5728\u6821\u9a8c\u6388\u6743…'; render(); if (!(await _ecr())) { if (!state.message || /\u6821\u9a8c\u6388\u6743/.test(state.message)) { state.message = '\u6388\u6743\u672a\u901a\u8fc7\uff0c\u8bf7\u586b\u5199 Token \u6216\u786e\u8ba4\u5df2\u767b\u5f55'; } pushLog(state.message); render(); return; } state.message = '\u6b63\u5728\u8bc6\u522b\u8003\u8bd5…'; render(); let target = null; try { target = await _rae(); } catch (error) { state.message = `\u8bc6\u522b\u8003\u8bd5\u5931\u8d25\uff1a${error.message || error}`; pushLog(state.message); render(); return; } if (!target || !target.examId) { state.message = '\u672a\u627e\u5230\u53ef\u53c2\u52a0\u7684\u8003\u8bd5\uff0c\u8bf7\u786e\u8ba4\u5217\u8868\u9875\u5df2\u6709\u8003\u8bd5\u4efb\u52a1'; pushLog(state.message); render(); return; } _aeh(target); const examToken = getExamToken(); if (!examToken) { state.message = '\u767b\u5f55\u5df2\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u767b\u5f55'; pushLog(state.message); render(); return; } state.running = true; state.stop = false; state.done = 0; state.matched = 0; state.missed = 0; state.total = 0; state.message = '\u7b54\u9898\u5904\u7406\u4e2d…'; pushLog(`\u5f00\u59cb\u5904\u7406\uff1a${state.examName || state.examId}`); render(); let wire = null; try { wire = await _crq('/api/gxpf/exam/run', 'POST', { lease: state.cloudLease, learning_user_id: currentUserId(), exam_token: examToken, exam_id: state.examId, paper_id: state.paperId || '', client_id: CLIENT_ID, auto_submit: true, ui_fill: false, num: target.num || q.num || null, }); } catch (error) { state.running = false; state.message = `\u5904\u7406\u5931\u8d25\uff1a${_afm(error.message || error)}`; pushLog(state.message); if (error.wire) _aqw(error.wire); render(); return; } _aqw(wire); state.total = Number(wire.total || 0); state.matched = Number(wire.matched || 0); state.missed = Number(wire.missed || 0); state.done = state.total; if (wire.examName) { state.examName = wire.examName; state.projectName = wire.examName; } if (wire.paperId) state.paperId = String(wire.paperId); if (wire.scoreNum != null && Number.isFinite(Number(wire.scoreNum))) { state.scoreNum = Number(wire.scoreNum); state.scoreText = wire.scoreText || `${state.scoreNum}\u5206`; } const submit = wire.submit || null; state.running = false; if (submit && submit.ok) { state.message = `\u5b8c\u6210 · ${submit.msg || '\u63d0\u4ea4\u6210\u529f'}`; } else if (submit && submit.skipped) { state.message = `\u5b8c\u6210 · \u672a\u63d0\u4ea4\uff08${submit.msg || 'skipped'}\uff09`; } else { state.message = '\u5904\u7406\u5b8c\u6210'; } pushLog(state.message); render(); } function stop() { state.stop = true; state.message = '\u6b63\u5728\u505c\u6b62…'; pushLog('\u7528\u6237\u505c\u6b62'); render(); } function tierText() { if (state.cloudTier === 'pro') return state.proExpiresText ? `Pro\uff08\u81f3 ${state.proExpiresText}\uff09` : 'Pro'; if (state.cloudTier === 'revoked') return '\u5df2\u7981\u7528'; if (state.cloudTier === 'bound') return '\u5df2\u7ed1\u5b9a\u5176\u4ed6\u8d26\u53f7'; return '\u9700\u5f00\u901a Pro'; } function isPassedByScore(scoreNum) { return Number.isFinite(scoreNum) && scoreNum >= PASS_SCORE; } function isExamFinished() { return isPassedByScore(state.scoreNum); } function _rei() { const q = parseQuery(); if (q.examId) state.examId = q.examId; if (q.paperId) state.paperId = q.paperId; if (q.examName) { try { state.examName = decodeURIComponent(q.examName); } catch { state.examName = q.examName; } state.projectName = state.examName; } if (isExamPage()) { const title = document.querySelector('.card-info .title, .title.font-bold'); if (title && title.textContent) { const t = title.textContent.trim(); if (t && t.length < 80) { state.projectName = t; state.examName = t; } } } } async function _fpn() { const base = String(state.baseUrl || DEFAULT_BASE).replace(/\/+$/, ''); try { const resp = await gmXhr({ url: `${base}/api/gxpf/panel-notice`, method: 'GET', timeout: 15000, headers: { Accept: 'text/plain,*/*' }, }); const t = String(resp.responseText || '').trim(); if (t && resp.status === 200) state.panelNotice = t; } catch {} try { const resp = await gmXhr({ url: `${base}/api/gxpf/client-config`, method: 'GET', timeout: 15000, headers: { Accept: 'application/json' }, }); const cfg = JSON.parse(String(resp.responseText || '{}') || '{}'); const buy = String(cfg.proBuyUrl || '').trim(); if (buy) state.proBuyUrl = buy; } catch {} } function _glp() { try { location.href = LIST_PAGE_URL; } catch { try { window.open(LIST_PAGE_URL, '_self'); } catch {} } } async function _sbp() { _rei(); if (isExamPage()) { state.message = LIST_PAGE_HINT; pushLog(state.message); render(); return; } if (isExamListPage()) { return _rcx(); } state.message = '\u8bf7\u6253\u5f00\u300c\u6211\u7684\u8003\u8bd5\u300d\u5217\u8868\u9875\u540e\u518d\u5f00\u59cb'; pushLog(state.message); render(); } function _ep() { if (document.getElementById('gx-auto-panel')) return; const style = document.createElement('style'); style.id = 'gx-panel-style'; style.textContent = ` #gx-auto-panel{position:fixed;right:20px;top:80px;z-index:2147483000;width:412px;display:flex;flex-direction:column;background:#f4f7fb;border:1px solid #dbe4f0;border-radius:16px;box-shadow:0 16px 40px rgba(15,23,42,.17);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"PingFang SC","Microsoft YaHei",sans-serif;font-size:12px;color:#0f172a;overflow:hidden;max-height:min(92vh,780px)} #gx-auto-panel.gx-min #gx-panel-body,#gx-auto-panel.gx-min #gx-panel-actions{display:none!important} #gx-panel-header{padding:8px 11px;background:linear-gradient(180deg,#e8f5ee,#dcefe4);border-bottom:1px solid #cfe3d7;display:flex;justify-content:space-between;align-items:flex-start;cursor:move;user-select:none;gap:8px} #gx-panel-brand{display:flex;align-items:flex-start;gap:8px;min-width:0;flex:1} #gx-panel-logo{width:28px;height:28px;border-radius:8px;object-fit:cover;background:#fff;border:1px solid #cfe3d7;flex:0 0 auto} #gx-panel-title{font-size:13px;font-weight:900;color:#166534;display:flex;align-items:center;gap:6px;flex-wrap:wrap} .gx-ver{font-size:11px;font-weight:900;color:#64748b;padding:2px 7px;border-radius:999px;background:#f1f5f9;border:1px solid #e2e8f0} #gx-panel-tags{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px} .gx-chip{font-size:10px;font-weight:800;padding:2px 7px;border-radius:999px;color:#1d4ed8;background:#eff6ff;border:1px solid #bfdbfe} .gx-chip-em{color:#166534;background:#ecfdf5;border-color:#86efac} .gx-chip-pro{color:#166534;background:#f0fdf4;border-color:#86efac} .gx-chip-free{color:#334155;background:#f8fafc;border-color:#cbd5e1} .gx-ctl{border:none;background:#fff;color:#64748b;width:28px;height:28px;border-radius:999px;cursor:pointer;box-shadow:0 1px 2px rgba(15,23,42,.1);font-weight:900;flex:0 0 auto} #gx-panel-body{flex:1;overflow-y:auto;padding:8px;min-height:0} .gx-card{background:#fff;border:1px solid #d9e2ee;border-radius:12px;padding:8px 10px;margin-bottom:7px} .gx-status-row{display:flex;justify-content:space-between;align-items:center;gap:7px} .gx-status-label{font-size:11px;color:#64748b;font-weight:700} #gx-auto-status{padding:2px 7px;border-radius:999px;font-weight:900;font-size:11px;background:#fff;border:1px solid #cbd5e1} .gx-meta-row{display:flex;justify-content:space-between;gap:7px;font-size:12px;margin-bottom:6px;align-items:flex-start} .gx-meta-label{color:#64748b;flex:0 0 72px}.gx-meta-value{font-weight:700;text-align:right;word-break:break-all;flex:1} .gx-input{width:100%;box-sizing:border-box;border:1px solid #cbd5e1;border-radius:8px;padding:6px 8px;font-size:12px;margin:4px 0 8px} .gx-btn-row{display:flex;gap:7px} .gx-btn{flex:1;border:none;color:#fff;padding:8px 9px;border-radius:10px;cursor:pointer;font-weight:800;font-size:12px} .gx-btn-start{background:#16a34a}.gx-btn-start:disabled{opacity:.55;cursor:not-allowed}.gx-btn-stop{background:#ef4444}.gx-btn-ghost{border:1px solid #cbd5e1;background:#fff;color:#0f172a} .gx-btn-pro{background:linear-gradient(135deg,#f59e0b,#ea580c);color:#fff} .gx-token-actions{display:flex;gap:7px;margin-bottom:4px} .gx-token-actions .gx-btn{flex:1} #gx-auto-status.is-done{color:#166534;border-color:#86efac;background:#f0fdf4} #gx-run-log{max-height:160px;overflow:auto;background:#f8fafc;border:1px solid #dbe4f0;border-radius:11px;padding:6px;margin-top:6px} .gx-log-row{padding:4px 6px;border-bottom:1px dashed #d4deea;line-height:1.4} #gx-panel-actions{padding:8px 10px;background:#eef2f7;border-top:1px solid #dbe4f0} .gx-msg{margin-top:6px;color:#64748b;white-space:pre-wrap;min-height:16px} .gx-exam-name{font-size:12px;font-weight:800;color:#0f172a;line-height:1.45;margin-top:6px} .gx-exam-score{margin-top:4px;color:#b45309;font-weight:800} .gx-section-label{font-size:11px;color:#64748b;font-weight:700;margin:8px 0 4px} .gx-ann{margin-top:8px;padding:7px 9px;border-radius:10px;background:#ecfdf5;border:1px solid #a7f3d0;color:#065f46;font-size:11px;line-height:1.45;white-space:pre-wrap;word-break:break-word} .gx-ann-label{font-weight:800;margin-right:4px} .gx-check{display:flex;align-items:center;gap:6px;margin:6px 0;color:#334155;font-weight:700} .gx-check input{accent-color:#16a34a} `; document.documentElement.appendChild(style); const tagsHtml = PANEL_TAGS.map((t, i) => `${escHtml(t)}`).join(''); const panel = document.createElement('div'); panel.id = 'gx-auto-panel'; panel.innerHTML = `