// ==UserScript== // @name 网课账号助手(自用) // @namespace wk-login-quick // @version 0.1.0 // @author useeseeu // @description 读取剪贴板并填充账号密码 // @license MIT // @match *://*.chaoxing.com/* // @match *://*.hexuezx.cn/* // @match *://*.webtrn.cn/* // @match *://*.sccchina.net // @match *://*.sccchina.net/* // @match https://os.open.com.cn/* // @match https://www.qingshuxuetang.com/Login // @match https://passport.qlteacher.com // @match https://passport.qlteacher.com/* // @match https://sso.dtdjzx.gov.cn/sso/login // @match *://*.xuehangyxt.com/log* // @require https://code.jquery.com/jquery-4.0.0.min.js // @grant GM_getValue // @grant GM_info // @grant GM_setValue // @run-at document-idle // ==/UserScript== (function () { 'use strict'; console.log('网课账号助手已启动'); const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms)); if (!navigator.clipboard) { return; } async function main() { try { await wait(500); const text = await navigator.clipboard.readText(); console.log('剪贴板内容:', text); if (!text) { console.log('剪贴板为空'); return; } var json; try { json = JSON.parse(text); } catch (e) { console.error('剪贴板内容不是有效的JSON格式'); return; } const p = json.p; const u = json.u; const pwd = json.pwd; if (!p || !u || !pwd) { console.error('JSON 格式缺少必要字段 (p, u, pwd)'); return; } if (p == 'hxzx') { $('input[type=text]').eq(2).val(u); $('input[type=password]').eq(0).val(pwd); } else if (p == 'rxzx') { $('input[name=username]').val(u); $('input[name=password]').val(pwd); } else if (p == 'xueqi') { $('input[name=username]').focus(); $('input[name=username]').val(u); $('input[name=password]').focus(); $('input[name=password]').val(pwd); $('input[name=Code]').focus(); } else if (p == 'aopeng') { $('#username').val(u); $('#password').val(pwd); } else if (p == 'qsxt') { $('#uname').val(u); $('#pwd').val(pwd); $('#user-pass-agree').prop('checked', true); $('#codeImg').click(); $('#vcode').focus(); } else if (p == 'qlteacher') { $('input[name=username]').val(u); $('.absolute ').click(); $('input[name=password]').focus(); $('input[name=password]').val(pwd); $('#password').val(pwd); } else if (p == 'dtdjzx') { $('input[name=username]').val(u); $('input[name=password]').val(pwd); $('input[name=validateCode]').focus(); } else if (p == 'tcm512') { $('input[type=tel]').val(u); $('input[type=password]').val(pwd); } else if (p == 'xuehang') { $('input[type=text]').val(u); $('input[type=password]').val(pwd); } else { console.log('未匹配到平台标识:', p); return; } console.log('填充成功!平台:', p); // 7. 填充后清空剪贴板 await navigator.clipboard.writeText(''); console.log('剪贴板已自动清空'); } catch (err) { console.error('执行出错:', err); if (err.name === 'NotAllowedError') { console.warn('⚠️ 权限被拦截:请点击页面空白处,脚本将自动重试...'); // 监听一次点击事件,点击后重新执行 main 函数 document.addEventListener('click', function retryHandler() { console.log('检测到点击,正在重试...'); // 移除监听器,防止重复触发 document.removeEventListener('click', retryHandler); // 重新运行主函数 main(); }, { once: true }); } } } $(document).ready(function() { main(); }); })();