// ==UserScript==
// @name 广东公需课自动刷课助手
// @namespace https://github.com/cxcs
// @version 1.1.5
// @description 自动播放、静音、答题、跳转下一节,支持页面刷新后自动恢复,浏览器页面可以不用显示在最上层
// @author CxCS
// @match https://ggfw.hrss.gd.gov.cn/zxpx/auc/play/player*
// @tag 刷课
// ==/UserScript==
(function () {
'use strict';
// 防止重复注入
if (window.__GD_AUTO_SCRIPT_ACTIVE__) return;
window.__GD_AUTO_SCRIPT_ACTIVE__ = true;
let isRunning = true; // 默认启动
let currentOptionIndex = 0;
let lastEjectId = null;
let hasSubmitted = false;
let hasAttemptedJump = false;
/**
* 控制面板 模块
*/
// 创建控制面板容器
const panelContainer = document.createElement('div');
panelContainer.id = 'gd-auto-panel-container';
panelContainer.style.cssText = `
position: fixed;
top: 10px;
left: 10px;
z-index: 999999;
`;
// 完整面板内容
const fullPanel = document.createElement('div');
fullPanel.id = 'gd-auto-full-panel';
fullPanel.innerHTML = `
广东公需课自动助手 v1.1.5
作\t 者:CxCS
自动播放·静音·答题·跳转下一章
`;
// 折叠后的小按钮
const collapseButton = document.createElement('button');
collapseButton.id = 'gd-collapse-btn';
collapseButton.innerText = '⚙️';
collapseButton.style.cssText = `
width: 36px;
height: 36px;
border-radius: 50%;
background: #2c3e50;
color: white;
border: none;
cursor: pointer;
box-shadow: 0 2px 6px rgba(0,0,0,0.3);
font-size: 14px;
display: none;
`;
// 默认显示完整面板
panelContainer.appendChild(fullPanel);
panelContainer.appendChild(collapseButton);
document.body.appendChild(panelContainer);
const toggleBtn = fullPanel.querySelector('#gd-toggle');
const startBtn = fullPanel.querySelector('#gd-start');
const stopBtn = fullPanel.querySelector('#gd-stop');
let isCollapsed = false;
function updateButtons() {
if (isRunning) {
startBtn.style.display = 'none';
stopBtn.style.display = 'block';
} else {
stopBtn.style.display = 'none';
startBtn.style.display = 'block';
}
}
// 切换折叠状态
toggleBtn.onclick = () => {
isCollapsed = true;
fullPanel.style.display = 'none';
collapseButton.style.display = 'block';
};
collapseButton.onclick = () => {
isCollapsed = false;
collapseButton.style.display = 'none';
fullPanel.style.display = 'block';
};
/*
启停脚本
*/
startBtn.onclick = () => {
isRunning = true;
hasAttemptedJump = false;
updateButtons();
console.log('[GD助手] 已启动');
};
stopBtn.onclick = () => {
isRunning = false;
updateButtons();
console.log('[GD助手] 已暂停');
};
updateButtons();
/**
* 静音模式
*/
function muteVideo() {
// 尝试原生静音
const videos = document.querySelectorAll('video');
let nativeMuted = false;
videos.forEach(video => {
if (video.src && (video.src.startsWith('blob:') || video.src.includes('m3u8'))) {
try {
video.volume = 0;
video.muted = true;
nativeMuted = true;
} catch (e) {}
}
});
// 强制修改音量条
const volumeValue = document.querySelector('.volume-value');
const volumeCursor = document.querySelector('.volume-cursor');
if (volumeValue && volumeCursor) {
volumeValue.style.height = '0%';
volumeCursor.style.bottom = '0%';
// 隐藏音量提示
const volumeTip = document.querySelector('.prism-info-display');
if (volumeTip) volumeTip.style.display = 'none';
console.log('[GD助手] 强制静音(音量条设为0%)');
return;
}
if (nativeMuted) {
console.log('[GD助手] 已通过