南京专技公需课答题助手
油猴脚本,需去火山引擎申请推理模型才可使用
// ==UserScript==
// @name 南京专技公需课助手 (V5.0)
// @namespace 匿名
// @version 5.0
// @description 进入答题页面,点击智能答题按钮,脚本自动答题。本脚本利用豆包AI实现,所以需要去火山引擎申请API Key和Model ID ,推荐申请Doubao-1.5-pro-32k|250115 模型使用。
// @author 匿名
// @match *://*.mynj.cn*/*
// @connect ark.cn-beijing.volces.com
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
const DEFAULT_API_URL = "https://ark.cn-beijing.volces.com/api/v3/chat/completions";
// --- 样式区域 ---
GM_addStyle(`
/* 主面板样式 */
#ai-panel {
position: fixed; top: 10px; right: 10px; width: 380px;
background: #fff; border: 2px solid #007ee2; box-shadow: 0 0 20px rgba(0,0,0,0.3);
z-index: 2147483647;
padding: 12px; font-family: "Microsoft YaHei", sans-serif; border-radius: 8px;
display: flex; flex-direction: column; max-height: 90vh;
transition: opacity 0.3s;
}
/* 标题栏布局 */
.panel-header {
display: flex; justify-content: space-between; align-items: center;
border-bottom: 1px solid #eee; padding-bottom: 8px; margin-bottom: 8px;
}
.panel-header h3 { margin: 0; font-size: 16px; color: #007ee2; font-weight: bold; }
.panel-minimize-btn {
cursor: pointer; font-size: 20px; line-height: 1; color: #666;
padding: 0 5px; transition: color 0.2s;
}
.panel-minimize-btn:hover { color: #007ee2; font-weight: bold; }
/* 悬浮球样式 (默认隐藏) */
#ai-float-ball {
position: fixed; top: 40%; right: 0;
width: 40px; height: 40px;
background: #007ee2; border-radius: 20px 0 0 20px;
color: #fff; font-size: 20px; text-align: center; line-height: 40px;
cursor: pointer; z-index: 2147483647;
box-shadow: -2px 2px 10px rgba(0,0,0,0.2);
display: none; /* 初始状态根据逻辑控制 */
transition: width 0.2s;
}
#ai-float-ball:hover { width: 50px; background: #005bb5; }
/* 内容区域 */
#ai-response-area {
width: 96%; height: 200px;
border: 1px solid #ccc; border-radius: 4px;
padding: 8px; font-size: 13px; line-height: 1.5; color: #333;
overflow-y: auto; margin-bottom: 8px; background: #f8f9fa; font-family: Consolas, monospace;
}
#log-window {
background: #2d2d2d; color: #eee;
font-family: Consolas, monospace; font-size: 11px;
padding: 8px; border-radius: 4px; margin-bottom: 8px;
flex-grow: 1; overflow-y: auto; height: 150px;
white-space: pre-wrap; word-break: break-all;
}
.log-match { color: #a6e22e; }
.log-warn { color: #e6db74; }
.log-err { color: #f92672; }
#ai-panel button { width: 100%; padding: 10px; cursor: pointer; background: #007ee2; color: #fff; border: none; border-radius: 4px; margin-bottom: 5px; font-size:14px; font-weight:bold;}
#ai-panel button:hover { background: #005bb5; }
#ai-panel button.secondary { background: #e9ecef; color: #495057; font-weight:normal; border:1px solid #ced4da; font-size:12px; padding:6px;}
#config-area { display: none; background: #f1f3f5; padding: 10px; border-radius:4px; margin-top: 5px;}
#config-area input { width: 95%; padding: 6px; margin-bottom: 6px; border: 1px solid #adb5bd; border-radius:3px;}
`);
// --- 日志 ---
function log(msg, type = '') {
const logWin = document.getElementById('log-window');
if (!logWin) return;
const line = document.createElement('div');
const time = new Date().toTimeString().split(' ')[0];
line.innerHTML = `<span style="opacity:0.5">[${time}]</span> ${msg}`;
if(type) line.className = type;
logWin.appendChild(line);
logWin.scrollTop = logWin.scrollHeight;
}
// --- UI 创建 ---
function createUI() {
if (document.getElementById('ai-panel')) return;
// 1. 创建悬浮球
const ball = document.createElement('div');
ball.id = 'ai-float-ball';
ball.innerHTML = '


