2025年寒假教师研修|仍然稳定运行|国家智慧教育公共服务平台|国家中小学智慧教育平台|秒拿到6学时
// ==UserScript==d
// @name 2025年寒假教师研修|仍然稳定运行|国家智慧教育公共服务平台|国家中小学智慧教育平台|秒拿到6学时
// @namespace http://tampermonkey.net/
// @version 1.15
// @description 智慧中小学自动学习工具
// @author beyondddd
// @match https://auth.smartedu.cn/*
// @match https://www.smartedu.cn/*
// @match https://basic.smartedu.cn/*
// @grant GM_xmlhttpRequest
// @copyright
// @license CUSTOM
// @connect zhihuizhongxiaoxue2.a1.luyouxia.net
// ==/UserScript==
(function() {
'use strict';
// 等待DOM加载完成
function initHelper() {
if (document.readyState !== 'complete') {
window.addEventListener('load', createHelper);
} else {
createHelper();
}
}
// 将原有的DOM创建和样式添加逻辑封装到函数中
function createHelper() {
// 检查是否已经存在助手界面
if (document.querySelector('.study-helper') || document.querySelector('.show-helper-button')) {
return;
}
// 创建样式
const style = document.createElement('style');
style.textContent = `
.study-helper {
position: fixed;
top: 20px;
right: 20px;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
width: 300px;
z-index: 10000;
}
.helper-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.helper-header h2 {
margin: 0;
color: #333;
font-size: 18px;
}
.hide-button {
background: none;
border: none;
color: #666;
font-size: 20px;
cursor: pointer;
padding: 0 5px;
width: auto !important;
}
.hide-button:hover {
color: #333;
}
.show-helper-button {
position: fixed;
top: 20px;
right: 20px;
background: #4CAF50;
color: white;
border: none;
border-radius: 4px;
padding: 8px 15px;
cursor: pointer;
z-index: 10000;
font-size: 14px;
transition: background-color 0.3s;
}
.show-helper-button:hover {
background: #45a049;
}
.study-helper .notice {
font-size: 14px;
color: #666;
margin-bottom: 15px;
line-height: 1.4;
}
.study-helper .input-group {
margin-bottom: 10px;
}
.study-helper label {
display: block;
margin-bottom: 5px;
color: #333;
font-size: 14px;
}
.study-helper input {
width: 100%;
padding: 8px;
margin-bottom: 0;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.study-helper button {
width: 100%;
padding: 10px;
background: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
.study-helper button:hover:not(:disabled) {
background: #45a049;
}
.study-helper button:disabled {
background: #cccccc;
cursor: not-allowed;
}
.study-helper .result {
margin-top: 10px;
padding: 10px;
border-radius: 4px;
font-size: 14px;
}
.study-helper .success {
background: #e8f5e9;
color: #2e7d32;
}
.study-helper .error {
background: #ffebee;
color: #c62828;
}
.study-helper .loading {
background: #fff3e0;
color: #ef6c00;
}
@keyframes spin {
0% { content: "?"; }
33% { content: "?"; }
66% { content: "?"; }
100% { content: "?"; }
}
.study-helper .loading::after {
content: "?";
display: inline-block;
margin-left: 5px;
animation: spin 1s infinite steps(4);
}
`;
document.head.appendChild(style);
// 创建HTML结构
const div = document.createElement('div');
div.className = 'study-helper';
div.innerHTML = `
<div class="helper-header">
<h2>智慧中小学学习助手</h2>
<button class="hide-button">×</button>
</div>
<div class="notice">
尊敬的用户你好,需要你输入username,password,和授权码,
授权码在<a href="https://www.qianxun1688.com/links/E46F5C6A" target="_blank">这里获取</a>,
注意,授权码有使用次数,请确认您的账号密码正确。<br>
如果油猴脚本无法使用,可以访问<a href="http://zhihuizhongxiaoxue2.a1.luyouxia.net:29429/" target="_blank">网页版</a>进行学习。
</div>
<div class="input-group">
<label for="helper-username">用户名:</label>
<input type="text" id="helper-username" class="helper-input" placeholder="请输入用户名" />
</div>
<div class="input-group">
<label for="helper-password">密码:</label>
<input type="password" id="helper-password" class="helper-input" placeholder="请输入密码" />
</div>
<div class="input-group">
<label for="helper-authcode">授权码:</label>
<input type="text" id="helper-authcode" class="helper-input" placeholder="请输入授权码" />
</div>
<button id="helper-submit">开始学习</button>
<div id="helper-result" class="result"></div>
`;
document.body.appendChild(div);
// 创建展开按钮(初始隐藏)
const showButton = document.createElement('button');
showButton.className = 'show-helper-button';
showButton.textContent = '显示学习助手';
showButton.style.display = 'none';
document.body.appendChild(showButton);
// 添加隐藏按钮事件处理
const hideButton = div.querySelector('.hide-button');
hideButton.addEventListener('click', function() {
div.style.display = 'none';
showButton.style.display = 'block';
});
// 添加展开按钮事件处理
showButton.addEventListener('click', function() {
div.style.display = 'block';
showButton.style.display = 'none';
});
// 添加提交事件处理
document.getElementById('helper-submit').addEventListener('click', function() {
const submitBtn = this;
const username = document.getElementById('helper-username').value.trim();
const password = document.getElementById('helper-password').value.trim();
const authcode = document.getElementById('helper-authcode').value.trim();
const resultDiv = document.getElementById('helper-result');
// 添加调试日志
console.log('发送的数据:', {
username: username,
password: password,
auth_code: authcode
});
if (!username || !password || !authcode) {
resultDiv.className = 'result error';
resultDiv.textContent = '请填写所有必要信息!';
return;
}
// 禁用按钮并显示加载状态
submitBtn.disabled = true;
submitBtn.textContent = '学习中';
resultDiv.className = 'result loading';
resultDiv.textContent = '正在执行学习任务,请耐心等待';
// 发送API请求
GM_xmlhttpRequest({
method: 'POST',
url: 'http://zhihuizhongxiaoxue2.a1.luyouxia.net:28226/api/study',
headers: {
'Content-Type': 'application/json'
},
data: JSON.stringify({
username: username,
password: password,
auth_code: authcode
}),
onload: function(response) {
console.log('服务器响应:', response.responseText);
try {
const result = JSON.parse(response.responseText);
if (response.status === 200) {
resultDiv.className = 'result success';
resultDiv.textContent = `${result.message},剩余使用次数:${result.remaining_uses}`;
submitBtn.textContent = '学习完成';
} else {
resultDiv.className = 'result error';
resultDiv.textContent = result.error || '请求失败,请稍后重试';
submitBtn.disabled = false;
submitBtn.textContent = '重试';
}
} catch (e) {
resultDiv.className = 'result error';
resultDiv.textContent = '解析响应失败,请稍后重试';
submitBtn.disabled = false;
submitBtn.textContent = '重试';
}
},
onerror: function(error) {
console.log('请求错误:', error);
resultDiv.className = 'result error';
resultDiv.textContent = '网络请求失败,请检查网络连接';
submitBtn.disabled = false;
submitBtn.textContent = '重试';
}
});
});
}
// 启动初始化
initHelper();
})();