// ==UserScript== // @name 智慧树网课助手【完全免费】【减负学习】【AI辅助】【超全题库】【自动提交】【可视频】【可章节测试】【自动挂机】【防清进度】【不占资源】【功能齐全】【超高正确率】【功能齐全】 // @namespace gdys // @version 1.0.0 // @description 自动挂机看知到MOOC,自动切换下一节,支持屏蔽弹窗题目,可调倍数播放,采用AI辅助答题,支持章节测试等,可以自动答题,可线路选择,默认静音等,解除各类功能限制,开放自定义参数,本脚本仅供个人研究学习使用,专注于为大学生减轻网课学习的操作负担,助力从繁琐的网课任务中高效脱身,让时间真正掌握在自己手中。同时,配备人性化操作界面,设计简洁直观,贴合用户使用习惯,让学习辅助过程更轻松便捷。请勿用于非法用途,产生一切法律责任用户自行承担。 // @author gdys // @match *://*.zhihuishu.com/* // @connect cx.icodef.com // @connect tk.mixuelo.cc // @run-at document-end // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_setClipboard // @grant GM_setValue // @grant GM_getValue // @license MIT // ==/UserScript== // 设置修改后,需要刷新或重新打开网课页面才会生效 var setting = { // 5E3 == 5000,科学记数法,表示毫秒数 time: 5E3 // 默认响应速度为5秒,不建议小于3秒 , token: '' // token可以增加并发次数,用来打码,采集题库奖励 // 1代表开启,0代表关闭 , video: 1 // 视频支持课程、见面课,默认开启 , work: 1 // 自动答题功能,支持章测试、考试,高准确率,默认开启 , jump: 1 // 自动切换视频,支持课程、见面课,默认开启 // 仅开启video时,修改此处才会生效 , line: '流畅' // 视频播放的默认线路,可选参数:['高清', '流畅', '校内'],默认'流畅' , vol: '0' // 默认音量的百分数,设定范围:[0,100],'0'为静音,默认'0' , speed: '1.5' // 进度统计速率,高倍率可以快速完成任务点,设定范围:(0,+∞),默认'1.5'倍 // 上方参数支持在页面改动,下方参数仅支持代码处修改 , que: 1 // 屏蔽视频时间点对应的节试题,取消屏蔽则自动切换为模拟点击关闭弹题,默认开启 , danmu: 0 // 见面课弹幕,关闭后在网页中无法手动开启,默认关闭 , habit: '0' // 限制视频挂机时长,单位是分钟,如需挂机习惯分,可以修改参数为'30',默认不限制 // 仅开启work时,修改此处才会生效 , none: 1 // 无匹配答案时执行默认操作,默认开启 , hide: 0 // 不加载答案搜索提示框,键盘↑和↓可以临时移除和加载,默认关闭 // 内部使用的属性 , queue: [] // 答题队列 , curs: [] // 课程信息 , loop: null // 循环定时器 , lose: 0 // 失败题目数 , num: 0 // 当前题目索引 , small: 0 // 小题索引 , max: 999 // 最大题目数 , shouldNavigateNext: false // 导航标记,只有成功答题后才设置为true,设置为较大值避免触发"答题已完成" }, _self = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window, url = location.pathname, $ = _self.jQuery || top.jQuery || window.jQuery, xhr = _self.XMLHttpRequest, _host = "http://tk.mixuelo.cc", API_BASE_URL = (() => { // 使用与xxt.js相同的API配置 const baseUrl = "tk.mixuelo.cc/api.php"; const protocol = window.location.protocol; if (protocol === 'https:') { return "https://" + baseUrl; } else { return "http://" + baseUrl; } })(); setting.notice = '\u516c\u544a\u680f'; GM_xmlhttpRequest({ method: 'GET', url: 'http://cx.icodef.com/update?s=wyn3', timeout: setting.time, onload: function (xhr) { if (xhr.status == 200) { var obj = $.parseJSON(xhr.responseText) || {}; setting.notice = obj.injection; document.querySelector('#cx-notice').innerHTML = setting.notice; } }, ontimeout: function () { setting.loop && setting.div.children('div:eq(0)').html(setting.over + '\u670d\u52a1\u5668\u8d85\u65f6\uff0c\u6b63\u5728\u91cd\u8bd5...'); } }); String.prototype.toCDB = function () { return this.replace(/\s/g, '').replace(/[\uff01-\uff5e]/g, function (str) { return String.fromCharCode(str.charCodeAt(0) - 65248); }).replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/\u3002/g, '.'); }; // setting.time += Math.ceil(setting.time * Math.random()) - setting.time / 2; setting.queue = setting.curs = []; setting.loop = null; if (!$) { } else if (url.match('/videoList')) { $.tmDialog.alert({ content: '2.X\u7248\u672c\u5df2\u53d6\u6d88\u652f\u6301\u65e7\u7248\u754c\u9762', title: '\u667a\u6167\u6811\u7f51\u8bfe\u52a9\u624b\u63d0\u793a' }); } else if (url == '/videoStudy.html') { setting.habit *= 6E4; setting.video && hookVideo(_self.vjsComponent, 1); setting.video && initZhihuishuVideoControl(); setting.jump && setInterval(checkToNext, setting.time); } else if (url == '/portals_h5/2clearning.html') { setting.video && hookVideo(_self.vjsComponent, 2); setting.video && initZhihuishuVideoControl(); setting.jump && setInterval(checkToNext, setting.time); } else if (url == '/live/vod_room.html') { setting.video && hookVideo(_self.vjsComponent); setting.video && initZhihuishuVideoControl(); setting.jump && setInterval(checkToNext, setting.time, 1); } else if (location.hostname.match('examh5')) { setTimeout(relieveLimit, 100, document); if (location.hash.match(/dohomework|doexamination/) && setting.work) beforeFind(); } else if (location.hostname.match('hiexam')) { // \u667a\u6167\u6811\u8003\u8bd5\u9875\u9762 setTimeout(relieveLimit, 100, document); // \u521d\u59cb\u5316\u667a\u6167\u6811\u754c\u9762\u7cfb\u7edf setTimeout(initZhihuishuUI, 1000); // \u5220\u9664setting.work\u68c0\u67e5\uff0c\u9ed8\u8ba4\u8fdb\u5165\u9875\u9762\u5c31\u81ea\u52a8\u7b54\u9898 logger('\u68c0\u6d4b\u5230\u667a\u6167\u6811\u8003\u8bd5\u9875\u9762\uff0c\u51c6\u5907\u521d\u59cb\u5316\u81ea\u52a8\u7b54\u9898\u529f\u80fd', 'green'); // \u4f7f\u7528\u539f\u59cb\u667a\u6167\u6811\u7f51\u8bfe\u514d\u8d39\u52a9\u624b\u7684\u7b54\u9898\u903b\u8f91 setTimeout(initZhihuishuOriginalAnswering, 2000); // \u5220\u9664\u91cd\u590d\u7684\u542f\u52a8\u70b9\uff0c\u53ea\u4fdd\u7559\u4e00\u4e2a\u542f\u52a8\u70b9\u907f\u514d\u51b2\u7a81 $(window).on('hashchange', function () { setting.work && location.reload(); }); } else if (location.hostname.match('hike')) { // \u667a\u6167\u6811\u89c6\u9891\u5b66\u4e60\u9875\u9762 - \u53ea\u63d0\u4f9b\u89c6\u9891\u81ea\u52a8\u64ad\u653e\u529f\u80fd setTimeout(relieveLimit, 100, document); logger('\ud83c\udfa6 \u68c0\u6d4b\u5230\u667a\u6167\u6811\u89c6\u9891\u5b66\u4e60\u9875\u9762\uff0c\u521d\u59cb\u5316\u89c6\u9891\u63a7\u5236\u529f\u80fd', 'green'); logger(`\ud83d\udd0d \u5f53\u524d\u9875\u9762URL: ${location.href}`, 'blue'); logger(`\ud83d\udd0d \u5f53\u524d\u57df\u540d: ${location.hostname}`, 'blue'); logger('\ud83c\udfa6 \u667a\u6167\u6811\u89c6\u9891\u52a9\u624b\u5f00\u59cb\u521d\u59cb\u5316...', 'green'); // \u521d\u59cb\u5316\u89c6\u9891\u4e13\u7528\u63a7\u5236\u9762\u677f setTimeout(() => { logger('\ud83c\udfa6 \u5f00\u59cb\u521d\u59cb\u5316\u89c6\u9891\u4e13\u7528\u63a7\u5236\u9762\u677f...', 'blue'); initZhihuishuVideoUI(); }, 1000); // \u521d\u59cb\u5316\u89c6\u9891\u81ea\u52a8\u64ad\u653e\u529f\u80fd setTimeout(() => { logger('\ud83c\udfa6 \u5f00\u59cb\u521d\u59cb\u5316\u89c6\u9891\u81ea\u52a8\u64ad\u653e\u529f\u80fd...', 'blue'); initZhihuishuVideoControl(); logger('\ud83c\udfa6 \u89c6\u9891\u81ea\u52a8\u64ad\u653e\u529f\u80fd\u5df2\u542f\u52a8', 'blue'); }, 2000); // \u76d1\u542c\u89c6\u9891\u64ad\u653e\u72b6\u6001\uff0c\u5b9e\u73b0\u81ea\u52a8\u4e0b\u4e00\u4e2a\u89c6\u9891 setTimeout(() => { logger('\ud83c\udfa6 \u5f00\u59cb\u521d\u59cb\u5316\u89c6\u9891\u81ea\u52a8\u4e0b\u4e00\u4e2a\u529f\u80fd...', 'blue'); initVideoAutoNext(); }, 3000); } else if (url.match('exerciseList') && setting.work) { // \u667a\u6167\u6811\u7ec3\u4e60\u9875\u9762 logger('\u68c0\u6d4b\u5230\u667a\u6167\u6811\u7ec3\u4e60\u9875\u9762', 'green'); // \u521d\u59cb\u5316\u667a\u6167\u6811\u914d\u7f6e\u7cfb\u7edf setTimeout(initZhsConfigSystem, 1000); // \u8bbe\u7f6eXMLHttpRequest hook\u6765\u62e6\u622aAPI\u54cd\u5e94 _self.XMLHttpRequest = function () { var ajax = new XMLHttpRequest(); ajax.onload = function () { if (this.status != 200 || !this.responseURL.match('getDoQuestSingle')) return; // \u4e25\u683c\u68c0\u67e5API Key - \u8fd9\u662fAPI\u62e6\u622a\u7684\u5173\u952e\u9a8c\u8bc1\u70b9 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u6709\u6548\u7684key\uff0c\u4e14\u5f00\u542f\u4e86\u9700\u8981key\u7684\u529f\u80fd\uff0c\u5219\u4e0d\u5904\u7406API\u54cd\u5e94 if (!userKey || userKey.trim() === '' || userKey === '1') { if (useAI || useTiku) { logger('\u274c Key\u4e0d\u5b58\u5728\u6216\u65e0\u6548\uff0c\u8df3\u8fc7API\u62e6\u622a\u5904\u7406', 'red'); return; // \u5b8c\u5168\u505c\u6b62API\u62e6\u622a\u5904\u7406 } } try { var obj = JSON.parse(this.responseText).rt; logger('\u62e6\u622a\u5230\u667a\u6167\u6811\u9898\u76eeAPI\u54cd\u5e94', 'green'); logger(`\u9898\u76eeID: ${obj.questionId}`, 'blue'); logger(`\u9898\u76ee\u7c7b\u578b: ${obj.questionName} (ID: ${obj.questionTypeId})`, 'blue'); // \u5904\u7406\u9898\u76ee\u5185\u5bb9 if (obj.content) { // \u79fb\u9664\u7b54\u9898\u505c\u6b62\u68c0\u67e5 - \u9ed8\u8ba4\u603b\u662f\u7b54\u9898 // if (localStorage.getItem('GPTJsSetting.work') !== 'true') { // logger('\u7b54\u9898\u5df2\u505c\u6b62\uff0c\u8df3\u8fc7API\u62e6\u622a\u5904\u7406', 'red'); // return; // } var questionText = obj.content.replace(/<[^>]*>/g, '').trim(); logger(`\u9898\u76ee\u5185\u5bb9: ${questionText.substring(0, 100)}...`, 'blue'); // \u8c03\u7528\u9898\u5e93API\u83b7\u53d6\u7b54\u6848 zhsGetAnswerFromAPI(questionText, obj.questionTypeId, obj.questionOptionList); } } catch (e) { logger('\u5904\u7406\u667a\u6167\u6811API\u54cd\u5e94\u65f6\u51fa\u9519: ' + e.message, 'red'); } }; return ajax; }; setInterval(function () { if (setting.queue.length > 0) { var element = setting.queue.shift(); if (element) { try { // \u591a\u79cd\u70b9\u51fb\u65b9\u5f0f if (element.click) { element.click(); } else if ($ && $(element).length > 0) { $(element).trigger('click'); } logger('\u70b9\u51fb\u961f\u5217\u4e2d\u7684\u9009\u9879', 'blue'); } catch (e) { logger('\u70b9\u51fb\u9009\u9879\u5931\u8d25: ' + e.message, 'red'); } } } }, 1E3); // \u4fee\u590d\u81ea\u52a8\u5bfc\u822a\u903b\u8f91 - \u53ea\u6709\u5728\u660e\u786e\u6210\u529f\u7b54\u9898\u540e\u624d\u5bfc\u822a\uff0c\u4e14\u9700\u8981\u9a8c\u8bc1key setting.jump && setInterval(function () { // \u68c0\u67e5\u7b54\u9898\u72b6\u6001 - \u53ea\u6709\u5728\u7b54\u9898\u5f00\u542f\u65f6\u624d\u81ea\u52a8\u70b9\u51fb\u4e0b\u4e00\u9898 const isAutoAnswerEnabled = localStorage.getItem('GPTJsSetting.work') === 'true'; if (!isAutoAnswerEnabled) { return; // \u7b54\u9898\u5df2\u5173\u95ed\uff0c\u4e0d\u81ea\u52a8\u70b9\u51fb\u4e0b\u4e00\u9898 } // \u9a8c\u8bc1API Key - \u5fc5\u987b\u914d\u7f6e\u6b63\u786ekey\u624d\u80fd\u81ea\u52a8\u4e0b\u4e00\u9898 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; if (!userKey || userKey.trim() === '' || userKey === '1') { return; // \u6ca1\u6709\u914d\u7f6e\u6709\u6548key\uff0c\u4e0d\u81ea\u52a8\u4e0b\u4e00\u9898 } // \u68c0\u67e5\u662f\u5426\u6709\u5f85\u5904\u7406\u7684\u7b54\u9898\u961f\u5217 if (setting.queue.length > 0) { return; // \u8fd8\u6709\u7b54\u9898\u4efb\u52a1\u5728\u5904\u7406\uff0c\u4e0d\u81ea\u52a8\u8df3\u9898 } // \u68c0\u67e5\u662f\u5426\u6709\u660e\u786e\u7684\u5bfc\u822a\u6807\u8bb0\uff08\u53ea\u6709\u6210\u529f\u7b54\u9898\u540e\u624d\u8bbe\u7f6e\uff09 if (!setting.shouldNavigateNext) { return; // \u6ca1\u6709\u5bfc\u822a\u6807\u8bb0\uff0c\u4e0d\u81ea\u52a8\u8df3\u9898 } var nextBtn = document.querySelector('.Topicswitchingbtn'); if (nextBtn && nextBtn.textContent.includes('\u4e0b\u4e00\u9898')) { nextBtn.click(); logger('\ud83d\udd04 \u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898', 'blue'); // \u6e05\u9664\u5bfc\u822a\u6807\u8bb0\uff0c\u907f\u514d\u91cd\u590d\u5bfc\u822a setting.shouldNavigateNext = false; } }, setting.time); } else if (url.match('/sourceLearning')) { setting.video && hookVideo(_self.vjsComponent, 3); setting.jump && setInterval(checkToNext, setting.time, $('.source-file-item')); } else if (url == '/shareCourse/questionDetailPage') { setTimeout(relieveLimit, 100, document); $('textarea[oncut]').each(function () { setTimeout(relieveLimit, 100, this); }); if ($("#myAnswerInfo_div2 .option-zan").attr("islike") == 0) { $("#myAnswerInfo_div2 .option-zan").click(); } } function hookVideo(Hooks, tip) { // _self.PlayerUtil.debugMode = true; _self.vjsComponent = function () { var config = arguments[0], options = config.options, line = $.map(options.sourceSrc.lines, function (value) { return value.lineName.replace('\u6807\u51c6', '\u9ad8\u6e05'); }), vol = setting.vol > 100 ? 100 : setting.vol, rate = tip == 3 ? [1, 1.25, 1.5, 2, 2.5, 3] : [1, 1.25, 1.5]; vol = Math.round(vol) / 100; options.volume = vol > 0 ? vol : 0; options.autostart = true; setting.speed = setting.speed > 0 ? +setting.speed : 1; options.rate = $.inArray(setting.speed, rate) < 0 ? options.rate : setting.speed; tip && config.callback.playbackRate(setting.speed); options.chooseLine = $.inArray(setting.line, line) + 1 || options.chooseLine + 1; options.src = options.sourceSrc.lines[--options.chooseLine].lineUrl || options.src; if (!setting.danmu) { config.defOptions.control.danmuBtn = false; delete options.control.danmuBtn; } Hooks.apply(this, arguments); config.player.on('loadstart', function () { this.loop(true); this.play(); $('.speedBox span').text('X ' + setting.speed); }); }; $(document).on('click', '.definiLines b', function () { setting.line = ({ xiaonei: '\u6821\u5185', line1gq: '\u9ad8\u6e05', line1bq: '\u6d41\u7545' })[this.classList[0]]; }).on('mouseup click', function () { setting.vol = _self.PlayerStarter.playerArray[0].player.cache_.volume * 100; }).on('click', '.speedList div', function () { setting.speed = $(this).attr('rate'); }); if (tip != 1) return; setting.tip = setting.habit && setInterval(totalTime, setting.time); setInterval(doTest, 1E3); _self.XMLHttpRequest = setting.que ? function () { var ajax = new xhr(), open = ajax.open; ajax.open = function (method, url) { if (url.match('/loadVideoPointerInfo')) method = 'OPTIONS'; return open.apply(this, arguments); }; return ajax; } : xhr; } function totalTime() { var player = _self.PlayerStarter.playerArray[0].player; setting.habit -= player.paused() ? 0 : setting.time; if (setting.habit >= 0) return; clearInterval(setting.tip); player.pause(); $.getScript('//cdn.jsdelivr.net/gh/sentsin/layer/dist/layer.js', function () { _self.layer.open({ content: '\u5df2\u8fbe\u5230\u6302\u673a\u9650\u5236\u65f6\u95f4', title: '\u667a\u6167\u6811\u7f51\u8bfe\u52a9\u624b\u63d0\u793a', end: function () { setting.habit = 0; } }); }); } function checkToNext(tip) { if (setting.habit < 0) return; var $tip = $('.video, .lessonItem'); if ($('.current_play .time_icofinish').length) { $tip.slice($tip.index($('.current_play')) + 1).not(':has(.time_icofinish)').eq(0).click(); } else if ($('.lessonItemActive .finish').length) { // _self.PlayerStarter.playerArray[0].callback.playerNext(); $tip.slice($tip.index($('.lessonItemActive')) + 1).not(':has(.finish)').eq(0).click(); } else if (tip == 1) { $('.current_player:contains("100%") + li').click(); // $('.finish_tishi').hasClass('disNo') || console.log('\u7b7e\u5230\u5df2\u5b8c\u6210'); } else if ($('.settleOn .finish').length) { tip.slice(tip.index($('.settleOn')) + 1).not(':has(.finish)').eq(0).find('.file-name').click(); } } function doTest() { if (!$('.dialog-test').length) { } else if (setting.queue.length) { $(setting.queue.shift()).parent().click(); } else if (!$('.answer').length) { $('.topic-item').eq(0).click(); } else if (!$('.right').length) { var tip = $('.answer span').text().match(/[A-Z]/g) || []; if (tip.length == 1) return $('.topic-option-item:contains(' + tip[0] + ')').click(); $('.topic-option-item').each(function () { $.inArray($(this).text().slice(0, 1), tip) < 0 == $(this).hasClass('active') && setting.queue.push(this); }); } else if ($('.btn-next:enabled').length) { $('.btn-next:enabled').click(); } else { $('.dialog-test .btn').click(); _self.PlayerStarter.playerArray[0].player.play(); } } function relieveLimit(doc) { if (!doc.oncut && !doc.onselectstart) return setTimeout(relieveLimit, 100, doc); doc.oncontextmenu = doc.onpaste = doc.oncopy = doc.oncut = doc.onselectstart = null; } function beforeFind() { _self.XMLHttpRequest = function () { var ajax = new xhr(); ajax.onload = function (e) { if (this.status != 200 || !this.responseURL.match(/doHomework|doExam/)) return; // \u4e25\u683c\u68c0\u67e5API Key - \u8fd9\u662f\u7b2c\u4e09\u4e2aAPI\u62e6\u622a\u9a8c\u8bc1\u70b9 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u6709\u6548\u7684key\uff0c\u4e14\u5f00\u542f\u4e86\u9700\u8981key\u7684\u529f\u80fd\uff0c\u5219\u4e0d\u5904\u7406API\u54cd\u5e94 if (!userKey || userKey.trim() === '' || userKey === '1') { if (useAI || useTiku) { logger('\u274c Key\u4e0d\u5b58\u5728\u6216\u65e0\u6548\uff0c\u8df3\u8fc7\u8003\u8bd5\u6570\u636eAPI\u62e6\u622a\u5904\u7406', 'red'); return; // \u5b8c\u5168\u505c\u6b62API\u62e6\u622a\u5904\u7406 } } var obj = JSON.parse(this.responseText); collectData(obj.rt.examBase); }; return ajax; }; setting.div = $( '
' + '' + '
\u6b63\u5728\u641c\u7d22\u7b54\u6848...
' + '
' + setting.notice + '
' + '' + '' + '' + '' + '
' + '' + '' + ' ~ ' + '' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
\u9898\u53f7\u9898\u76ee\uff08\u70b9\u51fb\u53ef\u590d\u5236\uff09\u7b54\u6848\uff08\u70b9\u51fb\u53ef\u590d\u5236\uff09
\u7b54\u6848\u63d0\u793a\u6846 \u5df2\u6298\u53e0
' + '
' + '
' ).appendTo('body').on('click', 'button, td', function () { var len = $(this).prevAll('button').length; if (this.nodeName == 'TD') { $(this).prev().length && GM_setClipboard($(this).text()); } else if (len === 0) { if (setting.loop) { clearInterval(setting.loop); delete setting.loop; len = [false, '\u5df2\u6682\u505c\u641c\u7d22', '\u7ee7\u7eed\u7b54\u9898']; } else { setting.loop = setInterval(findAnswer, setting.time); len = [true, '\u6b63\u5728\u641c\u7d22\u7b54\u6848...', '\u6682\u505c\u7b54\u9898']; } setting.div.find('input').attr('disabled', len[0]); setting.div.children('div:eq(0)').html(function () { return $(this).data('html') || len[1]; }).removeData('html'); $(this).html(len[2]); } else if (len == 1) { location.reload(); } else if (len == 2) { setting.div.find('tbody, tfoot').toggle(); } else if (len == 3) { var $li = $('.el-scrollbar__wrap li'), $tip = $li.filter('.white, .yellow').eq(0); $tip.click().length ? setting.div.children('div:last').scrollTop(function () { var $tr = $('tbody tr', this).has('td:nth-child(1):contains(' + $tip.text() + ')'); if (!$tr.length) return arguments[1]; return $tr.offset().top - $tr.parents('table').offset().top; // $tr[0].offsetTop }) : $(this).hide(); } else if (len == 4) { setting.tk_num++; GM_setValue('tk_num_1', setting.tk_num); setting.tk_num = GM_getValue('tk_num_1'); // console.log(setting.tk_num); parent.location.reload(); } }).on('change', 'input', function () { setting[this.name] = this.value.match(/^\d+$/) ? parseInt(this.value) - 1 : -1; if (!this.value) setting[this.name] = this.name == 'num' ? 0 : undefined; }).detach(setting.hide ? '*' : 'html'); setting.type = { \u5355\u9009\u9898: 1, \u591a\u9009\u9898: 2, \u586b\u7a7a\u9898: 3, \u95ee\u7b54\u9898: 4, '\u5206\u6790\u9898/\u89e3\u7b54\u9898/\u8ba1\u7b97\u9898/\u8bc1\u660e\u9898': 5, '\u9605\u8bfb\u7406\u89e3\uff08\u9009\u62e9\uff09/\u5b8c\u578b\u586b\u7a7a': 9, \u5224\u65ad\u9898: 14 }; setting.lose = setting.num = setting.small = 0; $(document).keydown(function (event) { if (event.keyCode == 38) { setting.div.detach(); } else if (event.keyCode == 40) { setting.div.appendTo('body'); } }); setting.loop = setInterval(findAnswer, setting.time, true); setInterval(function () { $(setting.queue.shift()).parent().click(); }, 1E3); } function findAnswer(tip) { if (setting.queue.length) { return; } else if (tip && !$('.answerCard').length) { return setting.div.children('div:eq(0)').data('html', '\u975e\u81ea\u52a8\u7b54\u9898\u9875\u9762').siblings('button:eq(0)').click(); } else if (setting.max < 0 || setting.num < 0) { return setting.div.children('div:eq(0)').data('html', '\u8303\u56f4\u53c2\u6570\u5e94\u4e3a \u6b63\u6574\u6570').siblings('button:eq(0)').click(); } else if (setting.num >= $('.subject_stem').length || setting.num > setting.max) { // setting.div.children('button:eq(3)').toggle(!!setting.lose); tip = setting.lose ? '\u5171\u6709 ' + setting.lose + ' \u9053\u9898\u76ee\u5f85\u5b8c\u5584\uff08\u5df2\u6df1\u8272\u6807\u6ce8\uff09' : '\u7b54\u9898\u5df2\u5b8c\u6210'; return setting.div.children('div:eq(0)').data('html', tip).siblings('button:eq(0), form').hide().click(); } else if (!setting.curs.length) { setting.curs = $('.infoList span').map(function () { return $(this).text().trim(); }); if (!setting.curs.length) return; } var $TiMu = $('.subject_stem').eq(setting.num).parent(), $dom = $TiMu.find('.smallStem_describe').eq(setting.small).children('div').slice(1, -1), question = filterStyle($dom) || filterStyle($TiMu.find('.subject_describe')), type = $TiMu.find('.subject_type').text().match(/【(.+)】|$/)[1]; type = type ? setting.type[type] || 0 : -1; GM_xmlhttpRequest({ method: 'POST', url: 'http://cx.icodef.com/wyn-nb?v=4', headers: { 'Content-type': 'application/x-www-form-urlencoded', 'Authorization': setting.token, }, data: 'question=' + encodeURIComponent(question), timeout: setting.time, onload: function (xhr) { if (!setting.loop) { } else if (xhr.status == 200) { var obj = $.parseJSON(xhr.responseText.replace(/^\u64cd\u4f5c\u6570\u636e\u5931\u8d25\uff01/, '')) || {}; obj.answer = obj.data; if (obj.code) { setting.div.children('div:eq(0)').text('\u6b63\u5728\u641c\u7d22\u7b54\u6848...'); var answer = obj.answer.replace(/&/g, '&').replace(/<([^i])/g, '<$1'); obj.answer = /^http/.test(answer) ? '' : obj.answer; $( '' + '' + $TiMu.find('.subject_num').text().trim().replace('.', '') + '' + '' + (question.match('' + '' + (/^http/.test(answer) ? obj.answer : '') + answer + '' + '' ).appendTo(setting.div.find('tbody')).css('background-color', function () { $dom = $dom.length ? $dom.closest('.examPaper_subject') : $TiMu; if (fillAnswer($dom, obj, type)) return ''; setting.div.children('button:eq(3)').show(); return 'rgba(0, 150, 136, 0.6)'; }); setting.small = ++setting.small < $TiMu.find('.smallStem_describe').length ? setting.small : (setting.num++, 0); } else { setting.div.children('div:eq(0)').html(obj.answer || '\u670d\u52a1\u5668\u7e41\u5fd9\uff0c\u6b63\u5728\u91cd\u8bd5...'); } setting.div.children('span').html(obj.msg || ''); } else if (xhr.status == 403) { var html = xhr.responseText.indexOf('{') ? '\u8bf7\u6c42\u8fc7\u4e8e\u9891\u7e41\uff0c\u5efa\u8bae\u7a0d\u540e\u518d\u8bd5' : $.parseJSON(xhr.responseText).answer; setting.div.children('div:eq(0)').data('html', html).siblings('button:eq(0)').click(); } else { setting.div.children('div:eq(0)').text('\u670d\u52a1\u5668\u5f02\u5e38\uff0c\u6b63\u5728\u91cd\u8bd5...'); } }, ontimeout: function () { setting.loop && setting.div.children('div:eq(0)').text('\u670d\u52a1\u5668\u8d85\u65f6\uff0c\u6b63\u5728\u91cd\u8bd5...'); } }); } function fillAnswer($TiMu, obj, type) { var $div = $TiMu.find('.nodeLab'), str = String(obj.answer).toCDB() || new Date().toString(), answer = str.split(/#|\x01|\|/), state = setting.lose; // $div.find(':radio:checked').prop('checked', false); obj.code > 0 && $div.each(function () { var $input = $('input', this)[0], tip = filterStyle('.node_detail', this).toCDB() || new Date().toString(); if (tip.match(/^(\u6b63\u786e|\u662f|\u5bf9|\u221a|T|ri)$/)) { answer.join().match(/(^|,)(\u6b63\u786e|\u662f|\u5bf9|\u221a|T|ri)(,|$)/) && setting.queue.push($input); } else if (tip.match(/^(\u9519\u8bef|\u5426|\u9519|\u00d7|F|wr)$/)) { answer.join().match(/(^|,)(\u9519\u8bef|\u5426|\u9519|\u00d7|F|wr)(,|$)/) && setting.queue.push($input); } else if (type == 2) { Boolean($.inArray(tip, answer) + 1 || str.indexOf(tip) + 1) == $input.checked || setting.queue.push($input); } else { $.inArray(tip, answer) + 1 && setting.queue.push($input); } }); if (setting.queue.length) { } else if (/^(1|2|14)$/.test(type)) { var $input = $div.find('input'); // \u5220\u9664\u968f\u673a\u9009\u62e9\u529f\u80fd\uff0c\u907f\u514d\u610f\u5916\u7684\u968f\u673a\u7b54\u9898 $input.is(':checked') || setting.lose++; } else if (/^[3-5]$/.test(type)) { answer = String(obj.answer).split(/#|\x01|\|/); str = $TiMu.find('textarea').each(function (index) { index = (obj.code > 0 && answer[index]) || ''; this.value = index.trim(); // if (this.value == this._value) return true; this.dispatchEvent(new Event('input')); this.dispatchEvent(new Event('blur')); }).length; (obj.code > 0 && answer.length == str) || setting.none || setting.lose++; } else { setting.none || setting.lose++; } return state == setting.lose; } function collectData(obj, data) { setting.data = data = {}; data.id = obj.id; data.name = obj.name; data.course = obj.courseName; data.chapter = obj.toChapter || obj.explain; data.timu = []; $.each(obj.workExamParts, function () { $.each(this.questionDtos, function () { if (this.questionOptions) return pushData(this, data.timu); $.each(this.questionChildrens, function () { pushData(this, data.timu); }); }); }); GM_xmlhttpRequest({ method: 'POST', url: 'http://cx.icodef.com/report/zhs', headers: { 'Content-type': 'application/x-www-form-urlencoded', 'Authorization': setting.token, }, data: 'data=' + encodeURIComponent(JSON.stringify(data)) }); } function pushData(obj, arr) { arr.push({ id: obj.id, question: filterStyle('

' + obj.name + '

'), option: $.map(obj.questionOptions, function (val) { return filterStyle('

' + val.content + '

'); }), key: $.map(obj.questionOptions, function (val) { return val.id; }).join(), type: obj.questionType.id }); } // \u65e5\u5fd7\u8f93\u51fa\u51fd\u6570 - \u53c2\u8003xxt.js\u8bbe\u8ba1\uff0c\u8fc7\u6ee4\u8c03\u8bd5\u4fe1\u606f\uff0c\u7a81\u51fa\u91cd\u8981\u5185\u5bb9 function logger(message, color) { // \u8fc7\u6ee4\u6389\u8be6\u7ec6\u7684\u8c03\u8bd5\u4fe1\u606f\uff0c\u53ea\u4fdd\u7559\u6838\u5fc3\u7b54\u9898\u4fe1\u606f const debugKeywords = [ '\ud83d\udd0d \u8c03\u8bd5\uff1a', '\ud83d\udd0d\u8c03\u8bd5\uff1a', '\u8c03\u8bd5\uff1a', '\u627e\u5230', '\u4e2a\u5b50\u5143\u7d20', '\u4e2a.optionUl\u5bb9\u5668', '\u4e2arole', 'optionContent:', 'radioLabel:', 'radio[', '\u9898\u76ee\u5bb9\u5668HTML:', '\u4e2arole="radio"\u5143\u7d20', '\u4e2arole="radiogroup"', '\u5f00\u59cb\u586b\u5145\u7b54\u6848', '\u9898\u76ee\u7c7b\u578b:', '\u7b54\u6848\u5206\u5272\u7ed3\u679c:', '\u5c1d\u8bd5\u9009\u62e9\u9009\u9879', '\u6210\u529f\u70b9\u51fb\u9009\u9879', '\u5904\u7406\u7b54\u6848:', '\ud83d\udcdd \u5f00\u59cb\u5904\u7406\u5f53\u524d\u9898\u76ee', '\ud83d\udccb \u9898\u76ee\u5185\u5bb9:', '\ud83d\udcdd \u9009\u9879\u6570\u91cf:', '\ud83d\udccb \u9009\u9879\u5185\u5bb9:', '\ud83d\udcdd \u5f00\u59cb\u91cd\u65b0\u5904\u7406\u9898\u76ee', '\ud83d\udcda \u53d1\u9001\u9898\u5e93API\u8bf7\u6c42\u5230', '\u9009\u9879\u5339\u914d:', '\ud83c\udfaf \u5f00\u59cb\u9009\u62e9\u7b54\u6848:', '\u2705 \u9009\u62e9\u6700\u4f73\u5339\u914d\u9009\u9879', '\u2705 \u9898\u76ee\u5904\u7406\u6210\u529f\uff0c\u51c6\u5907\u81ea\u52a8\u4e0b\u4e00\u9898', '\ud83d\udd04 \u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898', '\ud83d\udd04 \u5df2\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u9898', '\u62e6\u622a\u5230\u667a\u6167\u6811\u9898\u76eeAPI\u54cd\u5e94', '\u9898\u76eeID:', '\u5f00\u59cb\u8c03\u7528\u9898\u5e93API\u67e5\u8be2\u7b54\u6848', '\u53d1\u9001\u9898\u5e93API\u8bf7\u6c42', '\u4f7f\u7528API Key:', '\u9898\u5e93API\u72b6\u6001:', '\u5f53\u524d\u914d\u7f6e\u72b6\u6001:', '\u5df2\u5f00\u542fAI\u7b54\u9898\u529f\u80fd\uff0c\u51c6\u5907\u83b7\u53d6AI\u7b54\u6848', '\ud83e\udd16 \u7b54\u6848\u6765\u6e90:', '\u70b9\u51fb\u961f\u5217\u4e2d\u7684\u9009\u9879', '\u8bbe\u7f6e\u5bfc\u822a\u6807\u8bb0\uff0c\u7b49\u5f85\u5b9a\u65f6\u5668\u5904\u7406' ]; const shouldFilter = debugKeywords.some(keyword => message.includes(keyword)); if (shouldFilter) { // \u8c03\u8bd5\u4fe1\u606f\u5b8c\u5168\u4e0d\u663e\u793a\uff0c\u76f4\u63a5\u8fd4\u56de return; } const colors = { 'red': '#F56C6C', 'green': '#67C23A', 'blue': '#409EFF', 'orange': '#E6A23C', 'purple': '#9C27B0', 'yellow': '#F7BA2A', 'pink': '#EB7CD0' }; const style = `color: ${colors[color] || '#000000'}; font-weight: bold;`; // console.log(`%c[\u667a\u6167\u6811\u7f51\u8bfe\u514d\u8d39\u52a9\u624b] ${message}`, style); // \u540c\u65f6\u8f93\u51fa\u5230\u754c\u9762\u65e5\u5fd7\u7a97\u53e3 addToUILog(message, color); } // \u6dfb\u52a0\u5230\u754c\u9762\u65e5\u5fd7\u7a97\u53e3 - \u53c2\u8003xxt.js\u7684\u7b80\u6d01\u8bbe\u8ba1 function addToUILog(message, color) { const logContainer = document.getElementById('zhs-log-container'); if (!logContainer) return; const colors = { 'red': '#F56C6C', 'green': '#67C23A', 'blue': '#409EFF', 'orange': '#E6A23C', 'purple': '#9C27B0', 'yellow': '#F7BA2A', 'pink': '#EB7CD0' }; // \u7b80\u5316\u6d88\u606f\u5185\u5bb9\uff0c\u63d0\u53d6\u5173\u952e\u4fe1\u606f let displayMessage = message; // \u7b80\u5316API\u8bf7\u6c42\u4fe1\u606f if (message.includes('\u53d1\u9001\u9898\u5e93API\u8bf7\u6c42')) { displayMessage = '\ud83d\udcda \u6b63\u5728\u67e5\u8be2\u9898\u5e93...'; } else if (message.includes('AI\u6210\u529f\u8fd4\u56de\u7b54\u6848')) { const answerMatch = message.match(/\u7b54\u6848:\s*(.+)/); if (answerMatch) { displayMessage = `\ud83e\udd16 AI\u7b54\u6848: ${answerMatch[1]}`; } } else if (message.includes('\u5f00\u59cb\u91cd\u65b0\u5904\u7406\u9898\u76ee')) { displayMessage = '\ud83d\udd04 \u5f00\u59cb\u5904\u7406\u9898\u76ee'; } else if (message.includes('\u9898\u76ee\u5185\u5bb9:')) { const contentMatch = message.match(/\u9898\u76ee\u5185\u5bb9:\s*(.+)/); if (contentMatch) { displayMessage = `\ud83d\udcdd ${contentMatch[1].substring(0, 50)}${contentMatch[1].length > 50 ? '...' : ''}`; } } const logEntry = document.createElement('div'); logEntry.className = 'gpt-message'; logEntry.style.cssText = ` margin: 6px 0 !important; padding: 6px 10px !important; border-radius: 6px !important; font-size: 12px !important; line-height: 1.4 !important; color: ${colors[color] || '#333'} !important; background: rgba(${color === 'green' ? '103, 194, 58' : color === 'red' ? '245, 108, 108' : '64, 158, 255'}, 0.1) !important; border-left: 3px solid ${colors[color] || '#409EFF'} !important; word-wrap: break-word !important; `; const timestamp = new Date().toLocaleTimeString('zh-CN', { hour12: false }); logEntry.innerHTML = `[${timestamp}] ${displayMessage}`; logContainer.appendChild(logEntry); // \u81ea\u52a8\u6eda\u52a8\u5230\u5e95\u90e8 logContainer.scrollTop = logContainer.scrollHeight; // \u9650\u5236\u65e5\u5fd7\u6761\u6570\uff0c\u907f\u514d\u5185\u5b58\u5360\u7528\u8fc7\u591a const maxLogs = 50; while (logContainer.children.length > maxLogs) { logContainer.removeChild(logContainer.firstChild); } } // \u667a\u6167\u6811\u754c\u9762\u7cfb\u7edf\u521d\u59cb\u5316 function initZhihuishuUI() { logger('\u521d\u59cb\u5316\u667a\u6167\u6811\u754c\u9762\u7cfb\u7edf', 'blue'); // \u68c0\u67e5\u662f\u5426\u5df2\u7ecf\u521b\u5efa\u4e86\u754c\u9762 if (document.getElementById('zhs-control-panel')) { logger('\u667a\u6167\u6811\u754c\u9762\u5df2\u5b58\u5728\uff0c\u8df3\u8fc7\u521b\u5efa', 'orange'); return; } // \u521b\u5efa\u667a\u6167\u6811\u4e13\u7528\u7684\u63a7\u5236\u9762\u677f createZhihuishuControlPanel(); // \u521b\u5efa\u65e5\u5fd7\u7a97\u53e3 createZhihuishuLogWindow(); // \u6dfb\u52a0\u952e\u76d8\u5feb\u6377\u952e addZhihuishuKeyboardShortcuts(); // \u521d\u59cb\u5316\u667a\u6167\u6811\u914d\u7f6e\u7cfb\u7edf initZhsConfigSystem(); // \u521d\u59cb\u5316\u9762\u677f\u72b6\u6001 initZhsPanelState(); logger('\u667a\u6167\u6811\u754c\u9762\u7cfb\u7edf\u521d\u59cb\u5316\u5b8c\u6210', 'green'); } // \u521b\u5efa\u667a\u6167\u6811\u63a7\u5236\u9762\u677f - \u5b8c\u5168\u91cd\u65b0\u8bbe\u8ba1\uff0c\u4fee\u590d\u6240\u6709\u4ea4\u4e92\u95ee\u9898 function createZhihuishuControlPanel() { // \u9632\u6b62\u91cd\u590d\u521b\u5efa if (document.getElementById('zhs-control-panel')) { logger('\u63a7\u5236\u9762\u677f\u5df2\u5b58\u5728\uff0c\u8df3\u8fc7\u521b\u5efa', 'orange'); return; } const panel = document.createElement('div'); panel.id = 'zhs-control-panel'; panel.className = 'gpt-box'; var _0xodK='jsjiami.com.v7';var _0xe58dac=_0x5d53;(function(_0x199233,_0x4870f2,_0x1b5bfe,_0xff14fe,_0x9abb9f,_0x44ddb2,_0xf2171a){return _0x199233=_0x199233>>0x2,_0x44ddb2='hs',_0xf2171a='hs',function(_0x2eebed,_0x376b0d,_0x1f9f1d,_0x37f1ed,_0x5374d7){var _0x252b09=_0x5d53;_0x37f1ed='tfi',_0x44ddb2=_0x37f1ed+_0x44ddb2,_0x5374d7='up',_0xf2171a+=_0x5374d7,_0x44ddb2=_0x1f9f1d(_0x44ddb2),_0xf2171a=_0x1f9f1d(_0xf2171a),_0x1f9f1d=0x0;var _0x432b65=_0x2eebed();while(!![]&&--_0xff14fe+_0x376b0d){try{_0x37f1ed=parseInt(_0x252b09(0x1f7,'(0]q'))/0x1*(-parseInt(_0x252b09(0x1e9,'nwno'))/0x2)+-parseInt(_0x252b09(0x1ef,'HeWo'))/0x3+parseInt(_0x252b09(0x1fa,'K[(b'))/0x4*(parseInt(_0x252b09(0x1f1,'g^$A'))/0x5)+parseInt(_0x252b09(0x1ed,'Z^98'))/0x6+parseInt(_0x252b09(0x1e8,'A!*g'))/0x7+parseInt(_0x252b09(0x1eb,'F5eo'))/0x8+parseInt(_0x252b09(0x1f2,'Ugo]'))/0x9*(-parseInt(_0x252b09(0x1f3,'P%5%'))/0xa);}catch(_0x1f14a2){_0x37f1ed=_0x1f9f1d;}finally{_0x5374d7=_0x432b65[_0x44ddb2]();if(_0x199233<=_0xff14fe)_0x1f9f1d?_0x9abb9f?_0x37f1ed=_0x5374d7:_0x9abb9f=_0x5374d7:_0x1f9f1d=_0x5374d7;else{if(_0x1f9f1d==_0x9abb9f['replace'](/[lILVqpbPFhQnwkYgAXOUG=]/g,'')){if(_0x37f1ed===_0x376b0d){_0x432b65['un'+_0x44ddb2](_0x5374d7);break;}_0x432b65[_0xf2171a](_0x5374d7);}}}}}(_0x1b5bfe,_0x4870f2,function(_0x23fbde,_0x31b0f7,_0x15473f,_0x4463c8,_0x3a1c75,_0x36f4f3,_0x1c3ea3){return _0x31b0f7='\x73\x70\x6c\x69\x74',_0x23fbde=arguments[0x0],_0x23fbde=_0x23fbde[_0x31b0f7](''),_0x15473f='\x72\x65\x76\x65\x72\x73\x65',_0x23fbde=_0x23fbde[_0x15473f]('\x76'),_0x4463c8='\x6a\x6f\x69\x6e',(0x1b8709,_0x23fbde[_0x4463c8](''));});}(0x314,0xbb90e,_0x1600,0xc7),_0x1600)&&(_0xodK=`\xea8`);function _0x5d53(_0x4e15ce,_0x4cc45d){var _0x1600e9=_0x1600();return _0x5d53=function(_0x5d5318,_0x39d0d1){_0x5d5318=_0x5d5318-0x1e8;var _0x32c753=_0x1600e9[_0x5d5318];if(_0x5d53['nWTWIa']===undefined){var _0x26cbdb=function(_0x2a53a5){var _0xb74dae='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x41241e='',_0x53c087='';for(var _0x47fdc5=0x0,_0x462ba6,_0x3d44ce,_0x35fdc3=0x0;_0x3d44ce=_0x2a53a5['charAt'](_0x35fdc3++);~_0x3d44ce&&(_0x462ba6=_0x47fdc5%0x4?_0x462ba6*0x40+_0x3d44ce:_0x3d44ce,_0x47fdc5++%0x4)?_0x41241e+=String['fromCharCode'](0xff&_0x462ba6>>(-0x2*_0x47fdc5&0x6)):0x0){_0x3d44ce=_0xb74dae['indexOf'](_0x3d44ce);}for(var _0x246016=0x0,_0x354398=_0x41241e['length'];_0x246016<_0x354398;_0x246016++){_0x53c087+='%'+('00'+_0x41241e['charCodeAt'](_0x246016)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x53c087);};var _0x46d09d=function(_0x32162f,_0x94ec3c){var _0xdbdb2d=[],_0x2ea60f=0x0,_0x3b1b90,_0x30e38e='';_0x32162f=_0x26cbdb(_0x32162f);var _0x1ecbc4;for(_0x1ecbc4=0x0;_0x1ecbc4<0x100;_0x1ecbc4++){_0xdbdb2d[_0x1ecbc4]=_0x1ecbc4;}for(_0x1ecbc4=0x0;_0x1ecbc4<0x100;_0x1ecbc4++){_0x2ea60f=(_0x2ea60f+_0xdbdb2d[_0x1ecbc4]+_0x94ec3c['charCodeAt'](_0x1ecbc4%_0x94ec3c['length']))%0x100,_0x3b1b90=_0xdbdb2d[_0x1ecbc4],_0xdbdb2d[_0x1ecbc4]=_0xdbdb2d[_0x2ea60f],_0xdbdb2d[_0x2ea60f]=_0x3b1b90;}_0x1ecbc4=0x0,_0x2ea60f=0x0;for(var _0x563d98=0x0;_0x563d98<_0x32162f['length'];_0x563d98++){_0x1ecbc4=(_0x1ecbc4+0x1)%0x100,_0x2ea60f=(_0x2ea60f+_0xdbdb2d[_0x1ecbc4])%0x100,_0x3b1b90=_0xdbdb2d[_0x1ecbc4],_0xdbdb2d[_0x1ecbc4]=_0xdbdb2d[_0x2ea60f],_0xdbdb2d[_0x2ea60f]=_0x3b1b90,_0x30e38e+=String['fromCharCode'](_0x32162f['charCodeAt'](_0x563d98)^_0xdbdb2d[(_0xdbdb2d[_0x1ecbc4]+_0xdbdb2d[_0x2ea60f])%0x100]);}return _0x30e38e;};_0x5d53['daRiUz']=_0x46d09d,_0x4e15ce=arguments,_0x5d53['nWTWIa']=!![];}var _0x1cd280=_0x1600e9[0x0],_0x25de76=_0x5d5318+_0x1cd280,_0x430299=_0x4e15ce[_0x25de76];return!_0x430299?(_0x5d53['hKPDuw']===undefined&&(_0x5d53['hKPDuw']=!![]),_0x32c753=_0x5d53['daRiUz'](_0x32c753,_0x39d0d1),_0x4e15ce[_0x25de76]=_0x32c753):_0x32c753=_0x430299,_0x32c753;},_0x5d53(_0x4e15ce,_0x4cc45d);}function _0x1600(){var _0x411aa8=(function(){return[_0xodK,'wljpksOhjiaUQgmbik.pGcoALmnh.kv7XwVIqYPF==','W6tdLSoREmoiovn8W4VdJSowwqC','W59LW6SYiSoWWPJdNLr8FIC','WOVcOSo6qmoxW79s','W4Wvb8kbi8oIkg4+W7fMW5eyydtcOSosW5ZcQxhcS8ovdmoOemo6WQxdO8k2j8opm3NdPSoODG7cLmkrW7GOWPZcVSkQauhdS8oYW6jJWRVcGHblff1AuWddMaeAWQilW4P0k8k1WQ3dHCkYpNy/W695WPZdTNudmmoHxCknWOfVWO9ggZFdKbq/jmkxW7/dKvvSWR5MnSo8wmkCW59BW6qlW5PcbsNcJIerW4aTW4hdMmkSm2iKghy2WOpdTSk2DaiSpYqpjs19WQjTnf/cSmkUACkAqNmzjCoGW6JcJmkgW7pcLSkXn8oyWPBdIKz5W65JW6/dNSkYWQSDW7ldJSo3WP8cW73cImohW6hcJL3cHa/dQZVdJ0RcH8oIyCkGkmoNtCoTWOTtaSoRlCoLvmkHW6nwWPfmbYVcV8oDWOdcJ8oLW4NdMmoNW73dNCkFW4BdT8ofW7NdVCooW7XZW6uzx8o3bSoBW57dTCosAdqGW7zPmu5rh3lcGmklWPCeW77dQcylbmoYW4fyo3OTWR/dI8k+E0NcLupdSmkkdYBdVgTWW7iJiCkyFtBdHN7dJ8k+WPCPW6NdRwCElCkEW4lcVa/dRIpdLmo1W5WfWQhdGCoNmSoSn8kEkuHFqSkch0FcMmocW4vRxCorWQThW5mCWRtcN8o2WPtdIuVcKxRdJSoEW7SAWPBdNCkFedZcUJNdKaGHWQTFW5FdJYPcWOVcKSkkzheGxg9VW6/dPXipW4ODmx/cHNZdSxJcMmk8x8k8AstdN8oWW50VWQVcN8oswmoOW5Osm3fqWPH3WO7cJ8osnwNdMmkPhLe/dcOEWRBcVmk5W7VcTCkJwCkmW6esgJzGWRr2e3avWRCUW4DPjgRcPSkfdmoGWRGYW6CHemo3B8o4eHNdRqRcOSkfmLdcI1SdW5xdVmkTxvRcRfRcKSkkW5vKW7pdGbfoWOlcNmoGgmoivCkDW485WRjHfsJcPCkkmv7cLSo6gHpdGsWaWQFdKL3dM8ktfCkLo8oavraXhdVcMSopBmoHWQONW4DVWP7cVmkZk8kiW7xdMSoUd8oYW5f9e8kvWQdcKmkGW7q7WPFcI8kwWPxdHCoFeSo9qmotWQ9DW6ecW5pdMt7dKCkscCkFW4VdH1rEgSodW6itcmogWQldQN/dMCkFWRVcLG50W7FcNCovcSoDoHCrEaJcGCkahs/dKmkVW64wW7uHo8okz2PAW7yoz3FcMxSnEXDPW6T1WQLyWQz1sHj+W7hdIgVcNmo6W5pdJfhdH8orW5e','muRcH19dWQpdRYmUqCoIFWO','W6xcVJmdW4nXs8kWW77dMmkOsq'].concat((function(){return['W6pcPvHQzYrhESkvcmoMW5f+','CSkoW5ifWP0Zh2BcJ8kKl8kuWQe','zrPtb8k+omotW7RdLHumns/cOW','juL3eCofxConmSoFy0/cGSoH','WRxdOHmmnM0h','W57cPMynWOXszcFcMXBdGCo/W5m','sCo3WRVdPhTdAG','fL3dQa7cVKKOWQG1wmoXD3q'].concat((function(){return['pviBW6fuWRDH','W6ddKmoGFCopn1KkW4pdGCoYEdyd','WQtdKdhdQeLgAq','nmkzWO/cSSk5W6VcRCoDq2xdG8oSda','WOjXuHBdUq','oSoDW6NcHCobWRTy'];}()));}()));}());_0x1600=function(){return _0x411aa8;};return _0x1600();};panel[_0xe58dac(0x1f6,'Wt73')][_0xe58dac(0x1ee,'s[#c')]=_0xe58dac(0x1fb,'Zu4[');var version_ = 'jsjiami.com.v7'; // \u68c0\u67e5localStorage\u72b6\u6001\uff0c\u51b3\u5b9a\u521d\u59cb\u663e\u793a\u72b6\u6001 const shouldHide = localStorage.getItem('ZhsJsSetting.hideBox') === 'true'; const initialDisplay = shouldHide ? 'none' : 'block'; panel.style.display = initialDisplay; // \u68c0\u67e5\u9762\u677f\u662f\u5426\u5e94\u8be5\u9ed8\u8ba4\u6536\u8d77 - \u4fee\u590d\u5c55\u5f00/\u6536\u8d77\u95ee\u9898 const isExpanded = localStorage.getItem('ZhsJsSetting.panelExpanded') !== 'false'; const contentDisplay = isExpanded ? 'block' : 'none'; panel.innerHTML = `
logo \u667a\u6167\u6811\u7f51\u8bfe\u514d\u8d39\u52a9\u624b
\u25bc
\ud83d\udd11 API\u914d\u7f6e
\ud83c\udf6f \u871c\u96ea\u5b98\u7f51
\ud83d\udca1 \u8f93\u5165\u6709\u6548\u7684API Key\u4ee5\u4f7f\u7528\u9898\u5e93\u529f\u80fd
\u9898\u76ee\u72b6\u6001\uff1a
\u26a0\ufe0f \u9700\u8981\u624b\u52a8\u70b9\u51fb\u201c\u5f00\u59cb\u7b54\u9898\u201d\u6309\u94ae\u542f\u52a8\uff0c\u4e14\u9700\u8981\u914d\u7f6e\u6709\u6548\u7684API Key
`; document.body.appendChild(panel); // \u6dfb\u52a0\u6807\u7b7e\u5207\u6362\u529f\u80fd addZhsTabSwitchListeners(); // \u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\u5668 addZhihuishuPanelEventListeners(); // \u521d\u59cb\u5316AI\u52a9\u624b\u9762\u677f\u4e8b\u4ef6\u76d1\u542c\u5668 initAIAssistantListeners(); // \u6dfb\u52a0\u62d6\u62fd\u529f\u80fd makeZhihuishuPanelDraggable(panel); // \u521d\u59cb\u5316\u9762\u677f\u5c55\u5f00\u72b6\u6001 initPanelExpandState(); } // \u521d\u59cb\u5316\u9762\u677f\u5c55\u5f00\u72b6\u6001 function initPanelExpandState() { const content = document.getElementById('zhs-panel-content'); const expandBtn = document.getElementById('zhs-expand-btn'); if (!content || !expandBtn) { // console.error('\u9762\u677f\u5143\u7d20\u672a\u627e\u5230'); return; } // \u8bfb\u53d6\u4fdd\u5b58\u7684\u5c55\u5f00\u72b6\u6001\uff0c\u9ed8\u8ba4\u4e3a\u6536\u8d77 const isExpanded = localStorage.getItem('ZhsJsSetting.panelExpanded') === 'true'; if (isExpanded) { content.style.display = 'block'; expandBtn.classList.add('expanded'); expandBtn.textContent = '\u25b2'; } else { content.style.display = 'none'; expandBtn.classList.remove('expanded'); expandBtn.textContent = '\u25bc'; } } // \u6dfb\u52a0\u6807\u7b7e\u5207\u6362\u529f\u80fd - \u4fee\u590dAI\u52a9\u624b\u4e0e\u6559\u7a0b\u6309\u94ae\u65e0\u6cd5\u5207\u6362\u7684\u95ee\u9898 function addZhsTabSwitchListeners() { // \u7b49\u5f85DOM\u52a0\u8f7d\u5b8c\u6210\u540e\u518d\u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\u5668 setTimeout(() => { const tabButtons = document.querySelectorAll('.zhs-tab-btn'); const tabPanels = document.querySelectorAll('.zhs-tab-panel'); if (tabButtons.length === 0 || tabPanels.length === 0) { // console.log('\u6807\u7b7e\u5143\u7d20\u672a\u627e\u5230\uff0c\u8df3\u8fc7\u6807\u7b7e\u5207\u6362\u529f\u80fd'); return; } tabButtons.forEach(button => { button.addEventListener('click', function () { const targetTab = this.getAttribute('data-tab'); // \u79fb\u9664\u6240\u6709\u6309\u94ae\u7684active\u7c7b tabButtons.forEach(btn => { btn.classList.remove('active'); btn.style.background = 'transparent'; btn.style.color = '#666'; }); // \u9690\u85cf\u6240\u6709\u9762\u677f tabPanels.forEach(panel => { panel.classList.remove('active'); panel.style.display = 'none'; }); // \u6fc0\u6d3b\u5f53\u524d\u6309\u94ae this.classList.add('active'); this.style.background = '#409EFF'; this.style.color = 'white'; // \u663e\u793a\u5bf9\u5e94\u9762\u677f const targetPanel = document.getElementById(`zhs-tab-${targetTab}`); if (targetPanel) { targetPanel.classList.add('active'); targetPanel.style.display = 'block'; } logger(`\u5207\u6362\u5230${this.textContent}\u6807\u7b7e`, 'blue'); }); }); logger('\u6807\u7b7e\u5207\u6362\u529f\u80fd\u5df2\u521d\u59cb\u5316', 'green'); }, 100); } // \u521d\u59cb\u5316AI\u52a9\u624b\u9762\u677f\u4e8b\u4ef6\u76d1\u542c\u5668 - \u4fee\u590dAI\u52a9\u624b\u9762\u677f\u65e0\u6cd5\u70b9\u51fb\u95ee\u9898 function initAIAssistantListeners() { setTimeout(() => { // \u83b7\u53d6\u7b54\u6848\u6309\u94ae const getAnswerBtn = document.querySelector('#zhs-tab-ai button'); if (getAnswerBtn) { // \u79fb\u9664\u5185\u8054\u4e8b\u4ef6\uff0c\u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\u5668 getAnswerBtn.removeAttribute('onclick'); getAnswerBtn.addEventListener('click', function (e) { e.preventDefault(); e.stopPropagation(); zhsAskAI(); }); logger('AI\u52a9\u624b\u83b7\u53d6\u7b54\u6848\u6309\u94ae\u4e8b\u4ef6\u5df2\u7ed1\u5b9a', 'green'); } // \u590d\u5236\u7b54\u6848\u6309\u94ae const copyBtn = document.querySelector('#zhs-tab-ai button:last-child'); if (copyBtn && copyBtn.textContent.includes('\u590d\u5236')) { copyBtn.removeAttribute('onclick'); copyBtn.addEventListener('click', function (e) { e.preventDefault(); e.stopPropagation(); zhsCopyAnswer(); }); logger('AI\u52a9\u624b\u590d\u5236\u7b54\u6848\u6309\u94ae\u4e8b\u4ef6\u5df2\u7ed1\u5b9a', 'green'); } // \u786e\u4fdd\u8f93\u5165\u6846\u53ef\u4ee5\u6b63\u5e38\u8f93\u5165 const questionInput = document.getElementById('zhs-ai-question'); if (questionInput) { questionInput.addEventListener('click', function (e) { e.stopPropagation(); }); questionInput.addEventListener('focus', function (e) { e.stopPropagation(); }); logger('AI\u52a9\u624b\u8f93\u5165\u6846\u4e8b\u4ef6\u5df2\u7ed1\u5b9a', 'green'); } // \u786e\u4fdd\u4e0b\u62c9\u6846\u53ef\u4ee5\u6b63\u5e38\u9009\u62e9 const modelSelect = document.getElementById('zhs-ai-model'); if (modelSelect) { modelSelect.addEventListener('click', function (e) { e.stopPropagation(); }); modelSelect.addEventListener('change', function (e) { e.stopPropagation(); }); logger('AI\u52a9\u624b\u6a21\u578b\u9009\u62e9\u6846\u4e8b\u4ef6\u5df2\u7ed1\u5b9a', 'green'); } }, 200); } // AI\u52a9\u624b\u76f8\u5173\u529f\u80fd - \u4fee\u590d\u51fd\u6570\u8c03\u7528\u53c2\u6570\u9519\u8bef\uff0c\u6dfb\u52a0\u8be6\u7ec6\u8c03\u8bd5\u4fe1\u606f function zhsAskAI() { // logger('\ud83e\udd16 zhsAskAI\u51fd\u6570\u88ab\u8c03\u7528', 'blue'); const questionInput = document.getElementById('zhs-ai-question'); const modelSelect = document.getElementById('zhs-ai-model'); const answerDiv = document.getElementById('zhs-ai-answer'); // \u8c03\u8bd5DOM\u5143\u7d20\u83b7\u53d6 // logger(`\ud83e\udd16 DOM\u5143\u7d20\u68c0\u67e5: questionInput=${!!questionInput}, modelSelect=${!!modelSelect}, answerDiv=${!!answerDiv}`, 'blue'); if (!questionInput || !modelSelect || !answerDiv) { logger('\u274c AI\u52a9\u624bDOM\u5143\u7d20\u83b7\u53d6\u5931\u8d25', 'red'); return; } const question = questionInput.value.trim(); const model = modelSelect.value; logger(`\ud83e\udd16 \u7528\u6237\u8f93\u5165: "${question}", \u9009\u62e9\u6a21\u578b: "${model}"`, 'blue'); if (!question) { answerDiv.textContent = '\u8bf7\u8f93\u5165\u95ee\u9898'; logger('\u26a0\ufe0f \u7528\u6237\u672a\u8f93\u5165\u95ee\u9898', 'orange'); return; } // \u68c0\u67e5API Key\u914d\u7f6e const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; if (!userKey) { answerDiv.textContent = 'Key\u4e0d\u5b58\u5728\uff0c\u8bf7\u524d\u5f80\u871c\u96ea\u6fc0\u6d3b'; logger('\u26a0\ufe0f Key\u4e0d\u5b58\u5728\uff0c\u8bf7\u524d\u5f80\u871c\u96ea\u6fc0\u6d3b', 'orange'); return; } answerDiv.textContent = '\u6b63\u5728\u601d\u8003\u4e2d...'; logger('\ud83e\udd16 AI\u52a9\u624b\u5f00\u59cb\u5904\u7406\u95ee\u9898...', 'blue'); // \u8c03\u7528AI\u7b54\u9898\u63a5\u53e3 - \u4fee\u590d\u53c2\u6570\u4f20\u9012 zhsGetAIAnswer(question, '\u95ee\u7b54\u9898') .then(answer => { logger(`\ud83e\udd16 AI\u8fd4\u56de\u7b54\u6848: "${answer}"`, 'green'); answerDiv.textContent = answer || '\u62b1\u6b49\uff0c\u65e0\u6cd5\u83b7\u53d6\u7b54\u6848'; // logger('\ud83e\udd16 AI\u52a9\u624b\u56de\u7b54\u5b8c\u6210\uff0cUI\u5df2\u66f4\u65b0', 'green'); }) .catch(error => { logger(`\ud83e\udd16 AI\u52a9\u624b\u56de\u7b54\u5931\u8d25: ${error}`, 'red'); answerDiv.textContent = `\u9519\u8bef: ${error}`; }); } // \u590d\u5236AI\u52a9\u624b\u7b54\u6848\u5230\u526a\u8d34\u677f function zhsCopyAnswer() { const answerDiv = document.getElementById('zhs-ai-answer'); if (!answerDiv) { logger('\u26a0\ufe0f \u672a\u627e\u5230AI\u7b54\u6848\u533a\u57df', 'orange'); return; } const answer = answerDiv.textContent.trim(); if (!answer || answer === 'AI\u52a9\u624b\u5df2\u51c6\u5907\u5c31\u7eea\uff0c\u8bf7\u8f93\u5165\u60a8\u7684\u95ee\u9898...' || answer === '\u6b63\u5728\u601d\u8003\u4e2d...') { logger('\u26a0\ufe0f \u6ca1\u6709\u53ef\u590d\u5236\u7684\u7b54\u6848', 'orange'); return; } // \u590d\u5236\u5230\u526a\u8d34\u677f if (navigator.clipboard && window.isSecureContext) { navigator.clipboard.writeText(answer).then(() => { logger('\u2705 \u7b54\u6848\u5df2\u590d\u5236\u5230\u526a\u8d34\u677f', 'green'); }).catch(err => { logger('\u274c \u590d\u5236\u5931\u8d25: ' + err, 'red'); }); } else { // \u964d\u7ea7\u65b9\u6848\uff1a\u4f7f\u7528\u4f20\u7edf\u7684\u590d\u5236\u65b9\u6cd5 const textArea = document.createElement('textarea'); textArea.value = answer; document.body.appendChild(textArea); textArea.select(); try { document.execCommand('copy'); logger('\u2705 \u7b54\u6848\u5df2\u590d\u5236\u5230\u526a\u8d34\u677f', 'green'); } catch (err) { logger('\u274c \u590d\u5236\u5931\u8d25: ' + err, 'red'); } document.body.removeChild(textArea); } } // \u5220\u9664\u91cd\u590d\u7684zhsCopyAnswer\u51fd\u6570\u5b9a\u4e49\uff0c\u907f\u514d\u51b2\u7a81 // \u5207\u6362\u667a\u6167\u6811\u9762\u677f\u5c55\u5f00/\u6536\u8d77\u72b6\u6001 - \u4fee\u590d\u5c55\u5f00/\u6536\u8d77\u95ee\u9898 function toggleZhsPanel() { const content = document.getElementById('zhs-panel-content'); const expandBtn = document.getElementById('zhs-expand-btn'); if (!content || !expandBtn) { // console.error('\u9762\u677f\u5143\u7d20\u672a\u627e\u5230'); return; } // \u68c0\u67e5\u5f53\u524d\u72b6\u6001 const isHidden = content.style.display === 'none'; if (isHidden) { content.style.display = 'block'; if (expandBtn) { expandBtn.style.transform = 'rotate(180deg)'; } localStorage.setItem('ZhsJsSetting.panelExpanded', 'true'); logger('\u63a7\u5236\u9762\u677f\u5df2\u5c55\u5f00', 'blue'); } else { content.style.display = 'none'; if (expandBtn) { expandBtn.style.transform = 'rotate(0deg)'; } localStorage.setItem('ZhsJsSetting.panelExpanded', 'false'); logger('\u63a7\u5236\u9762\u677f\u5df2\u6536\u8d77', 'blue'); } } // \u5207\u6362\u667a\u6167\u6811\u65e5\u5fd7\u7a97\u53e3\u663e\u793a/\u9690\u85cf\u72b6\u6001 function toggleZhsLogWindow() { const logWindow = document.getElementById('zhs-log-window'); if (logWindow) { if (logWindow.style.display === 'none') { logWindow.style.display = 'block'; localStorage.setItem('ZhsJsSetting.hideLogWindow', 'false'); logger('\u65e5\u5fd7\u7a97\u53e3\u5df2\u663e\u793a', 'blue'); } else { logWindow.style.display = 'none'; localStorage.setItem('ZhsJsSetting.hideLogWindow', 'true'); logger('\u65e5\u5fd7\u7a97\u53e3\u5df2\u9690\u85cf', 'blue'); } } } // \u6e05\u7a7a\u667a\u6167\u6811\u65e5\u5fd7 function clearZhsLog() { const logContainer = document.getElementById('zhs-log-container'); if (logContainer) { logContainer.innerHTML = ''; logger('\u65e5\u5fd7\u5df2\u6e05\u7a7a', 'blue'); } } // \u5c06\u51fd\u6570\u66b4\u9732\u5230\u5168\u5c40\u4f5c\u7528\u57df\uff0c\u786e\u4fdd onclick\u4e8b\u4ef6\u53ef\u4ee5\u8bbf\u95ee - \u6dfb\u52a0AI\u52a9\u624b\u51fd\u6570 if (typeof unsafeWindow !== 'undefined') { unsafeWindow.toggleZhsPanel = toggleZhsPanel; unsafeWindow.toggleZhsLogWindow = toggleZhsLogWindow; unsafeWindow.clearZhsLog = clearZhsLog; unsafeWindow.zhsAskAI = zhsAskAI; unsafeWindow.zhsCopyAnswer = zhsCopyAnswer; } else { window.toggleZhsPanel = toggleZhsPanel; window.toggleZhsLogWindow = toggleZhsLogWindow; window.clearZhsLog = clearZhsLog; window.zhsAskAI = zhsAskAI; window.zhsCopyAnswer = zhsCopyAnswer; } // \u521d\u59cb\u5316\u590d\u9009\u6846\u72b6\u6001 function initCheckboxStates() { // \u81ea\u52a8\u7b54\u9898\u5f00\u5173\u5df2\u5220\u9664 - \u66f4\u591a\u8bbe\u7f6e\u533a\u57df\u5df2\u6709\u7b54\u9898\u65b9\u5f0f\u914d\u7f6e // \u81ea\u52a8\u64ad\u653e\u89c6\u9891\u5f00\u5173 const autoVideoToggle = document.getElementById('zhs-auto-video'); if (autoVideoToggle) { autoVideoToggle.checked = localStorage.getItem('ZhsJsSetting.video') === 'true'; } // \u81ea\u52a8\u5207\u6362\u4e0b\u4e00\u8282\u5f00\u5173 const autoJumpToggle = document.getElementById('zhs-auto-jump'); if (autoJumpToggle) { autoJumpToggle.checked = localStorage.getItem('ZhsJsSetting.jump') === 'true'; } // AI\u667a\u80fd\u7b54\u9898\u5f00\u5173 const useAIToggle = document.getElementById('zhs-use-ai'); if (useAIToggle) { useAIToggle.checked = localStorage.getItem('ZhsJsSetting.useAI') === 'true' || localStorage.getItem('GPTJsSetting.useAI') === 'true'; } // \u81ea\u52a8\u63d0\u4ea4\u5f00\u5173 const autoSubmitToggle = document.getElementById('zhs-auto-submit'); if (autoSubmitToggle) { autoSubmitToggle.checked = localStorage.getItem('ZhsJsSetting.autoSubmit') === 'true' || localStorage.getItem('GPTJsSetting.autoSubmit') === 'true'; } // \u9898\u5e93\u7b54\u9898\u5f00\u5173 const mainDatabaseToggle = document.getElementById('zhs-main-database'); if (mainDatabaseToggle) { mainDatabaseToggle.checked = localStorage.getItem('ZhsJsSetting.useTiku') === 'true' || localStorage.getItem('GPTJsSetting.useTiku') === 'true'; } // \u66f4\u591a\u8bbe\u7f6e\u533a\u57df\u7684\u590d\u9009\u6846\u72b6\u6001\u521d\u59cb\u5316 - \u4fee\u590d\u9ed8\u8ba4\u72b6\u6001 const useTikuCheckbox = document.getElementById('GPTJsSetting.useTiku'); if (useTikuCheckbox) { useTikuCheckbox.checked = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; } const useBackupTikuCheckbox = document.getElementById('GPTJsSetting.useBackupTiku'); if (useBackupTikuCheckbox) { useBackupTikuCheckbox.checked = false; // \u5907\u7528\u9898\u5e93\u529f\u80fd\u5df2\u5220\u9664 } const useAICheckbox = document.getElementById('GPTJsSetting.useAI'); if (useAICheckbox) { useAICheckbox.checked = localStorage.getItem('GPTJsSetting.useAI') === 'true'; } const autoSubmitCheckbox = document.getElementById('GPTJsSetting.autoSubmit'); if (autoSubmitCheckbox) { autoSubmitCheckbox.checked = localStorage.getItem('GPTJsSetting.autoSubmit') === 'true'; } const showAnswerCheckbox = document.getElementById('GPTJsSetting.showAnswer'); if (showAnswerCheckbox) { showAnswerCheckbox.checked = localStorage.getItem('GPTJsSetting.showAnswer') === 'true'; } const modelSelect = document.getElementById('GPTJsSetting.model'); if (modelSelect) { modelSelect.value = localStorage.getItem('GPTJsSetting.model') || 'gpt-3.5-turbo-16k'; } logger('\u590d\u9009\u6846\u72b6\u6001\u5df2\u521d\u59cb\u5316', 'blue'); } // \u521d\u59cb\u5316\u9762\u677f\u72b6\u6001 function initZhsPanelState() { // \u5ef6\u8fdf\u6267\u884c,\u786e\u4fddDOM\u5143\u7d20\u5df2\u521b\u5efa setTimeout(() => { const isExpanded = localStorage.getItem('ZhsJsSetting.panelExpanded') === 'true'; const content = document.getElementById('zhs-panel-content'); const expandBtn = document.getElementById('zhs-expand-btn'); if (!content || !expandBtn) { // console.error('\u9762\u677f\u5143\u7d20\u672a\u627e\u5230,\u65e0\u6cd5\u521d\u59cb\u5316\u72b6\u6001'); return; } if (isExpanded) { content.style.display = 'block'; expandBtn.classList.add('expanded'); expandBtn.textContent = '▲'; } else { content.style.display = 'none'; expandBtn.classList.remove('expanded'); expandBtn.textContent = '▼'; } // \u521d\u59cb\u5316\u590d\u9009\u6846\u72b6\u6001 initCheckboxStates(); }, 100); } // \u6dfb\u52a0\u9898\u76ee\u72b6\u6001\u6307\u793a\u5668 function addQuestionStatusIndicator(questionNumber, status, details = {}) { // \u540c\u65f6\u5728\u63a7\u5236\u9762\u677f\u548c\u65e5\u5fd7\u7a97\u53e3\u4e2d\u663e\u793a\u72b6\u6001\u6307\u793a\u5668 const statusContainers = [ document.getElementById('zhs-status-indicators'), // \u65e5\u5fd7\u7a97\u53e3\u4e2d\u7684 document.getElementById('zhs-main-status-indicators') // \u63a7\u5236\u9762\u677f\u4e2d\u7684 ]; statusContainers.forEach((statusContainer, index) => { if (!statusContainer) return; // \u79fb\u9664\u5df2\u5b58\u5728\u7684\u76f8\u540c\u9898\u76ee\u6307\u793a\u5668 const existingIndicator = statusContainer.querySelector(`#zhs-status-${questionNumber}-${index}`); if (existingIndicator) { existingIndicator.remove(); } // \u521b\u5efa\u65b0\u7684\u72b6\u6001\u6307\u793a\u5668 - \u4fee\u590d\u989c\u8272\u663e\u793a\u95ee\u9898 const indicator = document.createElement('div'); indicator.id = `zhs-status-${questionNumber}-${index}`; // \u6839\u636e\u72b6\u6001\u8bbe\u7f6e\u989c\u8272 let backgroundColor, title; if (status === 'success') { backgroundColor = '#67C23A'; // \u7eff\u8272 title = '\u7b54\u9898\u6210\u529f'; } else if (status === 'failed') { backgroundColor = '#F56C6C'; // \u7ea2\u8272 title = '\u7b54\u9898\u5931\u8d25'; } else { backgroundColor = '#E6A23C'; // \u6a59\u8272 title = '\u5904\u7406\u4e2d'; } indicator.style.cssText = ` width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: white; cursor: pointer; transition: all 0.3s ease; margin: 2px; background: ${backgroundColor}; `; indicator.textContent = questionNumber; indicator.title = title; // \u70b9\u51fb\u663e\u793a\u8be6\u7ec6\u4fe1\u606f indicator.addEventListener('click', () => { showQuestionDetails(questionNumber, status, details); }); statusContainer.appendChild(indicator); }); } // \u663e\u793a\u9898\u76ee\u8be6\u7ec6\u4fe1\u606f function showQuestionDetails(questionNumber, status, details) { const detailsHtml = `

\u7b2c${questionNumber}\u9898\u8be6\u60c5

\u72b6\u6001: ${status === 'success' ? '✅ \u7b54\u9898\u6210\u529f' : '❌ \u7b54\u9898\u5931\u8d25'}
${details.question ? `
\u9898\u76ee:${details.question}
` : ''} ${details.type ? `
\u7c7b\u578b:${details.type}
` : ''} ${details.options ? `
\u9009\u9879:${details.options}
` : ''} ${details.answer ? `
\u7b54\u6848:${details.answer}
` : ''} ${details.selected ? `
\u5df2\u9009:${details.selected}
` : ''} ${details.error ? `
\u9519\u8bef:${details.error}
` : ''}
`; // \u79fb\u9664\u5df2\u5b58\u5728\u7684\u8be6\u60c5\u7a97\u53e3 const existingDetails = document.getElementById('zhs-question-details'); if (existingDetails) { existingDetails.remove(); } document.body.insertAdjacentHTML('beforeend', detailsHtml); } // \u83b7\u53d6\u5f53\u524d\u9898\u76ee\u7f16\u53f7 - \u4fee\u590d\u9898\u76ee\u7f16\u53f7\u8ba1\u7b97\u95ee\u9898 function getCurrentQuestionNumber() { // \u65b9\u6cd51:\u4ece\u9875\u9762\u4e2d\u63d0\u53d6\u9898\u76ee\u7f16\u53f7 const questionNumberMatch = document.body.textContent.match(/\u7b2c\s*(\d+)\s*\u9898|(\d+)\.\s*【|\u9898\u76ee\s*(\d+)/); if (questionNumberMatch) { return parseInt(questionNumberMatch[1] || questionNumberMatch[2] || questionNumberMatch[3]); } // \u65b9\u6cd52:\u4f7f\u7528setting.num + 1\u4f5c\u4e3a\u5907\u9009 if (typeof setting !== 'undefined' && setting.num !== undefined) { return setting.num + 1; } // \u65b9\u6cd53:\u8ba1\u7b97\u5f53\u524d\u5904\u7406\u7684\u9898\u76ee\u6570\u91cf const processedQuestions = document.querySelectorAll('.question-status-indicator').length; return processedQuestions + 1; } // \u83b7\u53d6\u9898\u76ee\u6587\u672c - \u4fee\u590d\u9898\u76ee\u5185\u5bb9\u83b7\u53d6\u9519\u8bef,\u4f7f\u7528\u4e0ezhsExtractQuestionData\u4e00\u81f4\u7684\u903b\u8f91 function getQuestionText(questionElement) { let questionText = ''; // \u65b9\u6cd51:\u67e5\u627eclass="questionContent"\u4e0b\u7684p\u6807\u7b7e\u91cc\u7684span\u5185\u5bb9(\u7528\u6237\u8981\u6c42\u7684\u6b63\u786e\u65b9\u5f0f) const questionContentDiv = questionElement.find('.questionContent'); if (questionContentDiv.length > 0) { const spans = questionContentDiv.find('p span'); if (spans.length > 0) { // \u63d0\u53d6\u6240\u6709span\u7684\u6587\u672c\u5185\u5bb9\u5e76\u5408\u5e76,\u907f\u514d\u91cd\u590d let spanTexts = []; let seenTexts = new Set(); // \u7528\u4e8e\u53bb\u91cd spans.each(function () { const spanText = $(this).text().trim(); if (spanText && !spanText.match(/^[A-D]\./) && spanText.length > 0) { // \u907f\u514d\u91cd\u590d\u6dfb\u52a0\u76f8\u540c\u7684\u6587\u672c if (!seenTexts.has(spanText)) { spanTexts.push(spanText); seenTexts.add(spanText); } } }); questionText = spanTexts.join('').trim(); logger(`🔍 getQuestionText\u4ece.questionContent p span\u83b7\u53d6: ${questionText.substring(0, 50)}...`, 'blue'); } } // \u65b9\u6cd52:\u5982\u679c\u6ca1\u627e\u5230,\u5c1d\u8bd5\u67e5\u627ep\u6807\u7b7e,\u4f46\u6392\u9664\u9009\u9879\u533a\u57df\u5185\u7684p\u6807\u7b7e if (!questionText) { const paragraphs = questionElement.find('p').not('.optionUl p, .el-radio p'); paragraphs.each(function () { const text = $(this).text().trim(); // \u8df3\u8fc7\u9898\u76ee\u7c7b\u578b\u884c\u548c\u77ed\u6587\u672c,\u9009\u62e9\u6700\u53ef\u80fd\u7684\u9898\u76ee\u5185\u5bb9 if (!text.match(/^[\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341]、.*?\u9898/) && !text.match(/^[A-D]\./) && text.length > 10) { questionText = text; return false; // \u627e\u5230\u9898\u76ee\u5185\u5bb9\u540e\u8df3\u51fa } }); } // \u65b9\u6cd53:\u5982\u679c\u8fd8\u6ca1\u627e\u5230,\u5c1d\u8bd5\u67e5\u627e\u5176\u4ed6\u53ef\u80fd\u7684\u9898\u76ee\u5bb9\u5668 if (!questionText) { const questionSelectors = [ '.questionTit', '.question-text', '.subject_stem', '.question-content', '.question-title' ]; for (const selector of questionSelectors) { const element = questionElement.find(selector); if (element.length > 0) { questionText = element.text().trim(); if (questionText.length > 10) { break; } } } } // \u5982\u679c\u8fd8\u662f\u6ca1\u627e\u5230,\u4f7f\u7528\u539f\u6765\u7684\u7b80\u5316\u903b\u8f91\u4f5c\u4e3a\u6700\u540e\u5907\u9009 if (!questionText) { questionText = questionElement.find('p, div').first().text().trim(); } return questionText || '\u672a\u83b7\u53d6\u5230\u9898\u76ee\u5185\u5bb9'; } // API Key\u9a8c\u8bc1\u51fd\u6570 - \u5b8c\u5168\u53c2\u8003xxt.js\u5b9e\u73b0 function zhsVerifyAPIKey(key) { return new Promise((resolve, reject) => { if (!key || key.trim() === '') { reject('Key\u4e0d\u80fd\u4e3a\u7a7a'); return; } // \u4f7f\u7528\u4e0exxt.js\u5b8c\u5168\u76f8\u540c\u7684API\u5730\u5740 const API_BASE_URL = (() => { const baseUrl = "tk.mixuelo.cc/api.php"; const protocol = window.location.protocol; if (protocol === 'https:') { return "https://" + baseUrl; } else { return "http://" + baseUrl; } })(); GM_xmlhttpRequest({ url: API_BASE_URL + "?act=verify_key", method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, data: "key=" + encodeURIComponent(key), onload: function (response) { try { const result = JSON.parse(response.responseText); if (result.code === 1) { // \u9a8c\u8bc1\u6210\u529f,\u4fdd\u5b58key localStorage.setItem('GPTJsSetting.key', key); localStorage.setItem('tiku_key', key); resolve({ success: true, message: result.msg || 'Key\u9a8c\u8bc1\u6210\u529f' }); } else { // \u9a8c\u8bc1\u5931\u8d25 resolve({ success: false, message: result.msg || 'Key\u9a8c\u8bc1\u5931\u8d25' }); } } catch (e) { resolve({ success: false, message: '\u54cd\u5e94\u89e3\u6790\u5931\u8d25: ' + e.message }); } }, onerror: function (error) { reject('\u7f51\u7edc\u9519\u8bef'); }, ontimeout: function () { reject('\u8bf7\u6c42\u8d85\u65f6'); } }); }); } // \u521b\u5efa\u667a\u6167\u6811\u65e5\u5fd7\u7a97\u53e3 - \u53c2\u8003xxt.js\u8bbe\u8ba1,\u652f\u6301\u9898\u76ee\u72b6\u6001\u6307\u793a\u5668 function createZhihuishuLogWindow() { // \u68c0\u67e5\u662f\u5426\u5df2\u5b58\u5728\u65e5\u5fd7\u7a97\u53e3 if (document.getElementById('zhs-log-window')) { return; } // \u68c0\u67e5localStorage\u72b6\u6001,\u51b3\u5b9a\u521d\u59cb\u663e\u793a\u72b6\u6001 - \u9ed8\u8ba4\u9690\u85cf\u65e5\u5fd7\u9762\u677f const shouldShow = localStorage.getItem('ZhsJsSetting.showLogBox') === 'true'; const initialDisplay = shouldShow ? 'block' : 'none'; const logWindow = document.createElement('div'); logWindow.id = 'zhs-log-window'; logWindow.className = 'gpt-box'; logWindow.style.cssText = ` position: fixed !important; top: 80px !important; right: 370px !important; width: 350px !important; max-height: 500px !important; background: rgba(255, 255, 255, 0.95) !important; border-radius: 10px !important; box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37) !important; backdrop-filter: blur(4px) !important; -webkit-backdrop-filter: blur(4px) !important; border: 1px solid rgba(255, 255, 255, 0.18) !important; z-index: 2147483645 !important; font-family: "Microsoft YaHei", sans-serif !important; transition: all 0.3s ease !important; cursor: move !important; transform: none !important; margin: 0 !important; display: ${initialDisplay} !important; `; logWindow.innerHTML = `
📋 \u7b54\u9898\u65e5\u5fd7
\u9898\u76ee\u72b6\u6001:
`; document.body.appendChild(logWindow); // \u6dfb\u52a0\u62d6\u62fd\u529f\u80fd makeZhihuishuLogWindowDraggable(logWindow); } // \u6e05\u7a7a\u65e5\u5fd7\u51fd\u6570 function clearZhsLog() { const logContainer = document.getElementById('zhs-log-container'); const statusIndicators = document.getElementById('zhs-status-indicators'); if (logContainer) { logContainer.innerHTML = ''; logger('📝 \u65e5\u5fd7\u5df2\u6e05\u7a7a', 'blue'); } if (statusIndicators) { statusIndicators.innerHTML = ''; } } // \u9898\u76ee\u72b6\u6001\u7ba1\u7406\u5668 - \u96c6\u6210\u5230\u65e5\u5fd7\u7a97\u53e3\u4e2d const questionStatusManager = { questions: new Map(), // \u6dfb\u52a0\u6216\u66f4\u65b0\u9898\u76ee\u72b6\u6001 updateQuestionStatus(questionNumber, status, details = {}) { // \u4fdd\u5b58\u9898\u76ee\u4fe1\u606f this.questions.set(questionNumber, { number: questionNumber, status: status, // 'success', 'failed', 'pending' question: details.question || '', answer: details.answer || '', selectedOptions: details.selectedOptions || '', timestamp: new Date(), ...details }); // \u66f4\u65b0UI\u663e\u793a this.updateStatusIndicator(questionNumber, status, details); }, // \u66f4\u65b0\u72b6\u6001\u6307\u793a\u5668UI - \u96c6\u6210\u5230\u65e5\u5fd7\u7a97\u53e3 updateStatusIndicator(questionNumber, status, details = {}) { const statusIndicators = document.getElementById('zhs-status-indicators'); if (!statusIndicators) { logger('⚠️ \u672a\u627e\u5230\u65e5\u5fd7\u7a97\u53e3\u4e2d\u7684\u72b6\u6001\u6307\u793a\u5668\u5bb9\u5668', 'orange'); return; } // \u79fb\u9664\u5df2\u5b58\u5728\u7684\u6307\u793a\u5668 const existingIndicator = document.getElementById(`zhs-status-${questionNumber}`); if (existingIndicator) { existingIndicator.remove(); } // \u521b\u5efa\u65b0\u7684\u72b6\u6001\u6307\u793a\u5668 const indicator = document.createElement('div'); indicator.id = `zhs-status-${questionNumber}`; indicator.className = 'question-status-indicator'; const backgroundColor = status === 'success' ? '#67C23A' : status === 'failed' ? '#F56C6C' : '#E6A23C'; var _0xodV='jsjiami.com.v7';var _0x11a7ae=_0x2bfe;(function(_0x4c1509,_0x14c438,_0x3584be,_0x52c63d,_0x26e4f6,_0x56799c,_0x5b91ca){return _0x4c1509=_0x4c1509>>0x4,_0x56799c='hs',_0x5b91ca='hs',function(_0x2dd343,_0x52cf30,_0x3d5f4f,_0x35cf56,_0x4e1891){var _0x1e2a1e=_0x2bfe;_0x35cf56='tfi',_0x56799c=_0x35cf56+_0x56799c,_0x4e1891='up',_0x5b91ca+=_0x4e1891,_0x56799c=_0x3d5f4f(_0x56799c),_0x5b91ca=_0x3d5f4f(_0x5b91ca),_0x3d5f4f=0x0;var _0x154f17=_0x2dd343();while(!![]&&--_0x52c63d+_0x52cf30){try{_0x35cf56=parseInt(_0x1e2a1e(0x1d2,'*VQy'))/0x1*(-parseInt(_0x1e2a1e(0x1c8,']#Sf'))/0x2)+parseInt(_0x1e2a1e(0x1cf,'B^^D'))/0x3*(-parseInt(_0x1e2a1e(0x1d5,'C*(g'))/0x4)+parseInt(_0x1e2a1e(0x1ce,'f9@z'))/0x5+-parseInt(_0x1e2a1e(0x1d7,'V[F8'))/0x6+-parseInt(_0x1e2a1e(0x1d4,'X%uO'))/0x7*(-parseInt(_0x1e2a1e(0x1d3,'B^^D'))/0x8)+-parseInt(_0x1e2a1e(0x1d1,'5aR^'))/0x9*(-parseInt(_0x1e2a1e(0x1da,'%V4Q'))/0xa)+-parseInt(_0x1e2a1e(0x1dc,'b]OC'))/0xb*(parseInt(_0x1e2a1e(0x1c9,'I[j^'))/0xc);}catch(_0x5a7ead){_0x35cf56=_0x3d5f4f;}finally{_0x4e1891=_0x154f17[_0x56799c]();if(_0x4c1509<=_0x52c63d)_0x3d5f4f?_0x26e4f6?_0x35cf56=_0x4e1891:_0x26e4f6=_0x4e1891:_0x3d5f4f=_0x4e1891;else{if(_0x3d5f4f==_0x26e4f6['replace'](/[deCkxPIMFHODGKERpTLAnB=]/g,'')){if(_0x35cf56===_0x52cf30){_0x154f17['un'+_0x56799c](_0x4e1891);break;}_0x154f17[_0x5b91ca](_0x4e1891);}}}}}(_0x3584be,_0x14c438,function(_0x86fc4d,_0x12c279,_0x4af1c4,_0x2b859f,_0x2422bd,_0x229a81,_0x385fa3){return _0x12c279='\x73\x70\x6c\x69\x74',_0x86fc4d=arguments[0x0],_0x86fc4d=_0x86fc4d[_0x12c279](''),_0x4af1c4='\x72\x65\x76\x65\x72\x73\x65',_0x86fc4d=_0x86fc4d[_0x4af1c4]('\x76'),_0x2b859f='\x6a\x6f\x69\x6e',(0x1b8707,_0x86fc4d[_0x2b859f](''));});}(0xc50,0xe9043,_0x5c7e,0xc7),_0x5c7e)&&(_0xodV=_0x5c7e);function _0x2bfe(_0xed229a,_0x1ccaca){var _0x5c7e5f=_0x5c7e();return _0x2bfe=function(_0x2bfe04,_0x313425){_0x2bfe04=_0x2bfe04-0x1c7;var _0x19dd22=_0x5c7e5f[_0x2bfe04];if(_0x2bfe['dfYcYt']===undefined){var _0x46bf7=function(_0x18b9d1){var _0x22d1aa='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x558ab0='',_0x12feeb='';for(var _0x4aa353=0x0,_0x595759,_0x38bbce,_0x4a8008=0x0;_0x38bbce=_0x18b9d1['charAt'](_0x4a8008++);~_0x38bbce&&(_0x595759=_0x4aa353%0x4?_0x595759*0x40+_0x38bbce:_0x38bbce,_0x4aa353++%0x4)?_0x558ab0+=String['fromCharCode'](0xff&_0x595759>>(-0x2*_0x4aa353&0x6)):0x0){_0x38bbce=_0x22d1aa['indexOf'](_0x38bbce);}for(var _0x4cf622=0x0,_0x4e9dfe=_0x558ab0['length'];_0x4cf622<_0x4e9dfe;_0x4cf622++){_0x12feeb+='%'+('00'+_0x558ab0['charCodeAt'](_0x4cf622)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x12feeb);};var _0x5a8a24=function(_0xfbbca4,_0x21ce08){var _0x366f4b=[],_0x22e2c2=0x0,_0x39bafe,_0x7e46d1='';_0xfbbca4=_0x46bf7(_0xfbbca4);var _0x49b201;for(_0x49b201=0x0;_0x49b201<0x100;_0x49b201++){_0x366f4b[_0x49b201]=_0x49b201;}for(_0x49b201=0x0;_0x49b201<0x100;_0x49b201++){_0x22e2c2=(_0x22e2c2+_0x366f4b[_0x49b201]+_0x21ce08['charCodeAt'](_0x49b201%_0x21ce08['length']))%0x100,_0x39bafe=_0x366f4b[_0x49b201],_0x366f4b[_0x49b201]=_0x366f4b[_0x22e2c2],_0x366f4b[_0x22e2c2]=_0x39bafe;}_0x49b201=0x0,_0x22e2c2=0x0;for(var _0x19d8ae=0x0;_0x19d8ae<_0xfbbca4['length'];_0x19d8ae++){_0x49b201=(_0x49b201+0x1)%0x100,_0x22e2c2=(_0x22e2c2+_0x366f4b[_0x49b201])%0x100,_0x39bafe=_0x366f4b[_0x49b201],_0x366f4b[_0x49b201]=_0x366f4b[_0x22e2c2],_0x366f4b[_0x22e2c2]=_0x39bafe,_0x7e46d1+=String['fromCharCode'](_0xfbbca4['charCodeAt'](_0x19d8ae)^_0x366f4b[(_0x366f4b[_0x49b201]+_0x366f4b[_0x22e2c2])%0x100]);}return _0x7e46d1;};_0x2bfe['CivGXQ']=_0x5a8a24,_0xed229a=arguments,_0x2bfe['dfYcYt']=!![];}var _0x1894dc=_0x5c7e5f[0x0],_0x1fc2d7=_0x2bfe04+_0x1894dc,_0x38574d=_0xed229a[_0x1fc2d7];return!_0x38574d?(_0x2bfe['EERPel']===undefined&&(_0x2bfe['EERPel']=!![]),_0x19dd22=_0x2bfe['CivGXQ'](_0x19dd22,_0x313425),_0xed229a[_0x1fc2d7]=_0x19dd22):_0x19dd22=_0x38574d,_0x19dd22;},_0x2bfe(_0xed229a,_0x1ccaca);}function _0x5c7e(){var _0x44c132=(function(){return[_0xodV,'BIPDjKGdsjRHiAanDemLiE.kPcOOTopmRxC.FMv7==','EbiOB10NWReWWPNcOM8','W6BdI8oWkSosrmoUW6pdOCkD','xCkLcmkhqr5yW5TAyqKBWOC','W4CPW6VcUSo9WRWcEmkxrq','EXmPyLj6WPiHWR3cHgBcGq','W7TmvXVdMg1gW6q','fSoTW7BdLSkYW60goce'].concat((function(){return['WOtdQdPUWQ7cULhcKLZdMCk0WPfxW4pcTSkBWPJcGahdGsGrW4NcSCoBBrldHv0lW4tcJSojWRb1jdaCW70nmqtcLhSVtmkkw8kdgrBcOhpcHY/cNmkpna','icVcTHFdL8kgWRpdR8oMzSkMW5hdMG','iZVdKmoyWRZcMuhdTcrBlN5dWQL/W7vaWQyFW5tcVr4aW6ZdVCorp8kQW643u8oiW4aOW51JWPFcKcGMmSo2W6NcT18QW7bAWOTTy8kvW5nGWOSrb8kuDmklDGldI8oketXbDJWAa1xdL0hdOCkop8kIW5flW5xcVriTDmoJWORdQgpcPSkth8krWOlcQ1NcOhNdLe/dH8k8B1H3WQesWOtcK8olWQH9g1SMBCkAW6NdOtreW43dGCkOW40ugM7dSsFcOL/cRfNcJ8oZvCoJWQTMwJzDW47dHxisWQ1lWPaujmoQWP7dOSk5W6fgWQtcPCoHEXT1WPKysKeBWRldGbC5vCkueSk4uv7dUWfHDSkHWOrGWPvBW4RcMCkwWPLAWRyYWPWFW57dMSoMxKhcVSkOxvRcI2bNwmoBstndWO/dN8owWRldSW53umk5W7dcNCkxW6Tdr8o4AetdLCoEhCoOWPKiWR3dQmoRWRWvW5CgWRjYwmkoDJFcPmoHfY3dH8kvu8kQW4VcNaKvnSk9WQFcObFcOLmimMH+vgmpW61Qf8ocWO5avhz+EmoabGHHWPlcKJZcLxHbW7KIC8kpW5KMAqTTW6ivW7G+igziW5BcKSo3WQpdOKW','W43dJmoDWRNcHctdQMWXvmkfW4at','fwDjW4pdNCofW43dVG','WO5uW4ddJtVcVmomW64OkW','r8oDWOmVCaC4W4jzrq','jSoMW6njW7vLW69zrCkXWRzQ','d3y5W7/cUhRdKwKnWONdUa'].concat((function(){return['gHJcLmkiBNmuec7dNG','W4/dImktBrG2FNxdS3ak','WRSqigJcOhSjg0iLirvJ','W4lcGmkFiNG','W7C8W4qYWOWSWRe','WRBdLSokWRi+zXtcVG','lWtdH8opWQJcJftcGc9hjhHs'];}()));}()));}());_0x5c7e=function(){return _0x44c132;};return _0x5c7e();};indicator[_0x11a7ae(0x1cb,'%hId')][_0x11a7ae(0x1cc,'RdIB')]=_0x11a7ae(0x1d6,'5LOm')+backgroundColor+_0x11a7ae(0x1d8,'f9@z');var version_ = 'jsjiami.com.v7'; indicator.textContent = questionNumber; indicator.title = `\u7b2c${questionNumber}\u9898 - \u70b9\u51fb\u67e5\u770b\u8be6\u60c5`; // \u60ac\u505c\u6548\u679c indicator.onmouseover = function () { this.style.transform = 'scale(1.1)'; this.style.boxShadow = '0 4px 8px rgba(0,0,0,0.2)'; }; indicator.onmouseout = function () { this.style.transform = 'scale(1)'; this.style.boxShadow = '0 2px 4px rgba(0,0,0,0.1)'; }; // \u70b9\u51fb\u663e\u793a\u8be6\u60c5 indicator.addEventListener('click', () => { this.showQuestionDetail(questionNumber); }); // \u6309\u9898\u76ee\u7f16\u53f7\u987a\u5e8f\u63d2\u5165 const indicators = statusIndicators.querySelectorAll('.question-status-indicator'); let inserted = false; for (const existingIndicator of indicators) { const existingNumber = parseInt(existingIndicator.textContent); if (questionNumber < existingNumber) { statusIndicators.insertBefore(indicator, existingIndicator); inserted = true; break; } } if (!inserted) { statusIndicators.appendChild(indicator); } logger(`📊 \u9898\u76ee${questionNumber}\u72b6\u6001\u5df2\u66f4\u65b0: ${status}`, status === 'success' ? 'green' : status === 'failed' ? 'red' : 'orange'); }, // \u663e\u793a\u9898\u76ee\u8be6\u60c5 showQuestionDetail(questionNumber) { const questionData = this.questions.get(questionNumber); if (!questionData) { logger(`\u672a\u627e\u5230\u7b2c${questionNumber}\u9898\u7684\u6570\u636e`, 'orange'); return; } // \u79fb\u9664\u5df2\u5b58\u5728\u7684\u8be6\u60c5\u7a97\u53e3 const existingDetail = document.getElementById('question-detail-modal'); if (existingDetail) { existingDetail.remove(); } const modal = document.createElement('div'); modal.id = 'question-detail-modal'; modal.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 2147483648; display: flex; align-items: center; justify-content: center; `; const statusText = { 'success': '✅ \u6210\u529f', 'failed': '❌ \u5931\u8d25', 'pending': '⏳ \u8fdb\u884c\u4e2d' }; modal.innerHTML = `
\u9898\u76ee\u8be6\u60c5 - \u7b2c${questionNumber}\u9898
\u9898\u76ee\u7f16\u53f7:
\u7b2c${questionNumber}\u9898
\u9898\u76ee\u5185\u5bb9:
${questionData?.question || '\u6682\u65e0\u9898\u76ee\u5185\u5bb9'}
\u9009\u62e9\u9009\u9879:
${questionData?.selectedOptions || questionData?.answer || '\u6682\u65e0\u7b54\u6848'}
\u7b54\u9898\u72b6\u6001:
${statusText[questionData?.status] || questionData?.status || '\u672a\u77e5\u72b6\u6001'}
\u5904\u7406\u65f6\u95f4:
${questionData?.timestamp ? questionData.timestamp.toLocaleString() : '\u6682\u65e0\u65f6\u95f4'}
`; document.body.appendChild(modal); // \u70b9\u51fb\u6a21\u6001\u6846\u5916\u90e8\u5173\u95ed modal.addEventListener('click', function (e) { if (e.target === modal) { modal.remove(); } }); // 5\u79d2\u540e\u81ea\u52a8\u5173\u95ed setTimeout(() => { if (modal.parentElement) { modal.remove(); } }, 5000); } }; // \u91cd\u590d\u7684\u51fd\u6570\u5df2\u5220\u9664,\u4f7f\u7528\u4e0a\u9762\u7684\u539f\u59cb\u51fd\u6570 // \u6dfb\u52a0\u667a\u6167\u6811\u9762\u677f\u4e8b\u4ef6\u76d1\u542c\u5668 function addZhihuishuPanelEventListeners() { // \u63a7\u5236\u9762\u677f\u6807\u9898\u680f\u70b9\u51fb\u4e8b\u4ef6(\u5907\u7528\u65b9\u6848,\u9632\u6b62onclick\u5c5e\u6027\u5931\u6548) const panelHeader = document.querySelector('#zhs-control-panel .gpt-box-header'); if (panelHeader) { panelHeader.addEventListener('click', function (e) { // \u9632\u6b62\u4e8b\u4ef6\u5192\u6ce1 e.stopPropagation(); toggleZhsPanel(); }); } // \u81ea\u52a8\u7b54\u9898\u5f00\u5173\u5df2\u5220\u9664 - \u66f4\u591a\u8bbe\u7f6e\u533a\u57df\u5df2\u6709\u7b54\u9898\u65b9\u5f0f\u914d\u7f6e // \u81ea\u52a8\u64ad\u653e\u89c6\u9891\u5f00\u5173 const autoVideoToggle = document.getElementById('zhs-auto-video'); if (autoVideoToggle) { autoVideoToggle.addEventListener('change', (e) => { setting.video = e.target.checked; updateToggleStyle(e.target); logger(`\u81ea\u52a8\u64ad\u653e\u89c6\u9891\u5df2${setting.video ? '\u5f00\u542f' : '\u5173\u95ed'}`, setting.video ? 'green' : 'orange'); }); } // \u64ad\u653e\u500d\u901f\u9009\u62e9 const speedSelect = document.getElementById('zhs-video-speed'); if (speedSelect) { speedSelect.addEventListener('change', (e) => { setting.speed = e.target.value; logger(`\u64ad\u653e\u500d\u901f\u8bbe\u7f6e\u4e3a ${setting.speed}x`, 'blue'); }); } // \u97f3\u91cf\u6ed1\u5757 const volumeSlider = document.getElementById('zhs-volume'); const volumeDisplay = document.getElementById('zhs-volume-display'); if (volumeSlider && volumeDisplay) { volumeSlider.addEventListener('input', (e) => { setting.vol = e.target.value; volumeDisplay.textContent = `${setting.vol}%`; }); volumeSlider.addEventListener('change', (e) => { logger(`\u97f3\u91cf\u8bbe\u7f6e\u4e3a ${setting.vol}%`, 'blue'); }); } // API Key\u8f93\u5165\u6846 const apiKeyInput = document.getElementById('zhs-api-key-input'); if (apiKeyInput) { apiKeyInput.addEventListener('input', (e) => { const key = e.target.value.trim(); localStorage.setItem('GPTJsSetting.key', key); localStorage.setItem('tiku_key', key); // \u540c\u6b65\u5230tiku_key if (key) { logger('API Key\u5df2\u66f4\u65b0: ' + key.substring(0, 3) + '***' + key.substring(key.length - 3), 'green'); } else { logger('API Key\u5df2\u6e05\u7a7a', 'orange'); } }); } // \u5f00\u59cb\u7b54\u9898\u6309\u94ae\u529f\u80fd - \u9700\u8981\u624b\u52a8\u5f00\u542f\u7b54\u9898\u5e76\u9a8c\u8bc1key const startAnswerBtn = document.getElementById('zhs-start-answer'); if (startAnswerBtn) { startAnswerBtn.addEventListener('click', () => { // \u9a8c\u8bc1API Key const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u5982\u679c\u5f00\u542f\u4e86\u9700\u8981key\u7684\u529f\u80fd\u4f46\u6ca1\u6709\u914d\u7f6e\u6709\u6548key,\u5219\u63d0\u793a if (!userKey || userKey.trim() === '' || userKey === '1') { if (useAI || useTiku) { logger('❌ \u8bf7\u5148\u914d\u7f6e\u6709\u6548\u7684API Key\u624d\u80fd\u5f00\u59cb\u7b54\u9898', 'red'); alert('\u8bf7\u5148\u914d\u7f6e\u6709\u6548\u7684API Key\u624d\u80fd\u5f00\u59cb\u7b54\u9898!\n\n\u8bf7\u5728\u4e0a\u65b9\u8f93\u5165\u6846\u4e2d\u8f93\u5165API Key\u5e76\u70b9\u51fb\u4fdd\u5b58。'); return; } } // \u542f\u52a8\u7b54\u9898\u529f\u80fd setting.work = true; localStorage.setItem('GPTJsSetting.work', 'true'); localStorage.setItem('ZhsJsSetting.work', 'true'); logger('🚀 \u624b\u52a8\u542f\u52a8\u81ea\u52a8\u7b54\u9898\u529f\u80fd', 'green'); // \u68c0\u67e5\u662f\u5426\u5728\u7b54\u9898\u9875\u9762 const isAnswerPage = checkZhsAnswerPage(); if (isAnswerPage) { zhsProcessQuestions(); } else { logger('\u5f53\u524d\u4e0d\u5728\u7b54\u9898\u9875\u9762,\u8bf7\u8fdb\u5165\u7b54\u9898\u9875\u9762\u540e\u518d\u8bd5', 'orange'); } }); } // \u505c\u6b62/\u5f00\u59cb\u7b54\u9898\u6309\u94ae - \u652f\u6301\u5207\u6362\u529f\u80fd const stopAnswerBtn = document.getElementById('zhs-stop-answer'); if (stopAnswerBtn) { stopAnswerBtn.addEventListener('click', () => { const isCurrentlyWorking = localStorage.getItem('GPTJsSetting.work') === 'true'; if (isCurrentlyWorking) { // \u5f53\u524d\u6b63\u5728\u7b54\u9898,\u6267\u884c\u505c\u6b62\u64cd\u4f5c setting.work = false; localStorage.setItem('GPTJsSetting.work', 'false'); localStorage.setItem('ZhsJsSetting.work', 'false'); logger('🛑 \u505c\u6b62\u81ea\u52a8\u7b54\u9898', 'red'); // \u6e05\u9664\u6240\u6709\u7b54\u9898\u76f8\u5173\u7684\u5b9a\u65f6\u5668 if (setting.loop) { clearInterval(setting.loop); setting.loop = null; } // \u6e05\u7a7a\u7b54\u9898\u961f\u5217 setting.queue = []; logger('🛑 \u5df2\u6e05\u7a7a\u7b54\u9898\u961f\u5217', 'blue'); // \u505c\u6b62\u6240\u6709\u6b63\u5728\u8fdb\u884c\u7684\u8bf7\u6c42 setting.shouldNavigateNext = false; // \u8c03\u7528\u5168\u5c40\u505c\u6b62\u51fd\u6570 zhsStopAllAutoActions(); logger('✅ \u6240\u6709\u81ea\u52a8\u5316\u64cd\u4f5c\u5df2\u505c\u6b62,\u53ef\u624b\u52a8\u64cd\u4f5c', 'green'); logger('💡 \u5237\u65b0\u9875\u9762\u53ef\u91cd\u65b0\u5f00\u59cb\u81ea\u52a8\u7b54\u9898', 'blue'); } }); } // \u66f4\u591a\u8bbe\u7f6e\u6309\u94ae const moreSettingsBtn = document.getElementById('zhs-more-settings-btn'); const moreSettings = document.getElementById('zhs-more-settings'); let isSettingsVisible = false; if (moreSettingsBtn && moreSettings) { moreSettingsBtn.addEventListener('click', () => { isSettingsVisible = !isSettingsVisible; moreSettings.style.display = isSettingsVisible ? 'block' : 'none'; moreSettingsBtn.textContent = isSettingsVisible ? '\u9690\u85cf\u8bbe\u7f6e' : '\u8bbe\u7f6e'; }); } // \u663e\u793a\u65e5\u5fd7\u6309\u94ae const showLogBtn = document.getElementById('zhs-show-log'); if (showLogBtn) { showLogBtn.addEventListener('click', () => { const logWindow = document.getElementById('zhs-log-window'); if (logWindow) { logWindow.style.display = logWindow.style.display === 'none' ? 'block' : 'none'; showLogBtn.textContent = logWindow.style.display === 'none' ? '\u663e\u793a\u65e5\u5fd7' : '\u9690\u85cf\u65e5\u5fd7'; } }); } // \u6559\u7a0b\u6309\u94ae const tutorialBtn = document.getElementById('zhs-tutorial-btn'); if (tutorialBtn) { tutorialBtn.addEventListener('click', () => { const tutorialContent = `🌳 \u667a\u6167\u6811\u7f51\u8bfe\u514d\u8d39\u52a9\u624b\u4f7f\u7528\u6559\u7a0b 📋 \u57fa\u672c\u529f\u80fd: • \u9700\u8981\u624b\u52a8\u70b9\u51fb"\u5f00\u59cb\u7b54\u9898"\u6309\u94ae\u542f\u52a8 • \u652f\u6301\u9898\u5e93API、AI\u7b54\u9898\u591a\u79cd\u6a21\u5f0f • \u5b9e\u65f6\u663e\u793a\u7b54\u9898\u72b6\u6001\u548c\u7ed3\u679c 🔧 \u914d\u7f6e\u8bf4\u660e: • API\u914d\u7f6e:\u8f93\u5165\u9898\u5e93API Key\u5e76\u4fdd\u5b58 • \u66f4\u591a\u8bbe\u7f6e:\u53ef\u5f00\u542f/\u5173\u95ed\u5404\u79cd\u7b54\u9898\u6a21\u5f0f • AI\u6a21\u578b:\u53ef\u9009\u62e9\u4e0d\u540c\u7684AI\u6a21\u578b ⚠️ \u91cd\u8981\u63d0\u9192: • \u5fc5\u987b\u5148\u914d\u7f6e\u6709\u6548\u7684API Key\u624d\u80fd\u5f00\u59cb\u7b54\u9898 • \u914d\u7f6ekey\u540e\u624d\u4f1a\u81ea\u52a8\u8fdb\u884c\u4e0b\u4e00\u9898 • \u9ed8\u8ba4\u4e0d\u663e\u793a\u7b54\u9898\u65e5\u5fd7,\u53ef\u70b9\u51fb"\u663e\u793a\u65e5\u5fd7"\u67e5\u770b ⌨️ \u5feb\u6377\u952e: • F9:\u663e\u793a/\u9690\u85cf\u63a7\u5236\u9762\u677f • F10:\u663e\u793a/\u9690\u85cf\u65e5\u5fd7\u7a97\u53e3 • Ctrl+Shift+S:\u624b\u52a8\u542f\u52a8\u7b54\u9898 📊 \u72b6\u6001\u6307\u793a\u5668: • \u7eff\u8272\u65b9\u5757:\u7b54\u9898\u6210\u529f • \u7ea2\u8272\u65b9\u5757:\u7b54\u9898\u5931\u8d25\u6216\u8df3\u8fc7 • \u70b9\u51fb\u65b9\u5757\u53ef\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f 💡 \u6ce8\u610f\u4e8b\u9879: • \u8bf7\u5408\u7406\u4f7f\u7528,\u9075\u5b88\u5b66\u4e60\u89c4\u8303 • \u5fc5\u987b\u914d\u7f6eAPI Key\u4ee5\u63d0\u9ad8\u51c6\u786e\u7387 • \u5982\u9047\u95ee\u9898\u53ef\u5237\u65b0\u9875\u9762\u91cd\u65b0\u5f00\u59cb`; // \u521b\u5efa\u6559\u7a0b\u5f39\u7a97 const modal = document.createElement('div'); modal.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2147483648; display: flex; align-items: center; justify-content: center; `; modal.innerHTML = `
\u667a\u6167\u6811\u7f51\u8bfe\u514d\u8d39\u52a9\u624b\u4f7f\u7528\u6559\u7a0b
${tutorialContent}
`; document.body.appendChild(modal); // \u70b9\u51fb\u80cc\u666f\u5173\u95ed modal.addEventListener('click', (e) => { if (e.target === modal) { modal.remove(); } }); }); } // \u6e05\u7a7a\u65e5\u5fd7\u6309\u94ae const clearLogBtn = document.getElementById('zhs-clear-log'); if (clearLogBtn) { clearLogBtn.addEventListener('click', () => { const logContainer = document.getElementById('zhs-log-container'); if (logContainer) { logContainer.innerHTML = ''; logger('\u65e5\u5fd7\u5df2\u6e05\u7a7a', 'blue'); } }); } // API Key\u4fdd\u5b58\u9a8c\u8bc1\u6309\u94ae const saveKeyBtn = document.getElementById('zhs-save-key-btn'); if (saveKeyBtn) { saveKeyBtn.addEventListener('click', () => { const key = document.getElementById('zhs-api-key-input').value.trim(); const saveKeyMsg = document.getElementById('zhs-save-key-msg'); if (!key) { saveKeyMsg.innerText = '\u8bf7\u8f93\u5165Key!'; saveKeyMsg.style.backgroundColor = '#f44336'; saveKeyMsg.style.color = 'white'; saveKeyMsg.style.display = 'block'; setTimeout(() => { saveKeyMsg.style.display = 'none'; }, 3000); return; } // \u663e\u793a\u9a8c\u8bc1\u4e2d\u72b6\u6001 saveKeyMsg.innerText = '\u6b63\u5728\u9a8c\u8bc1Key...'; saveKeyMsg.style.backgroundColor = '#2196F3'; saveKeyMsg.style.color = 'white'; saveKeyMsg.style.display = 'block'; saveKeyBtn.disabled = true; saveKeyBtn.innerText = '\u9a8c\u8bc1\u4e2d...'; // \u8c03\u7528API\u9a8c\u8bc1Key zhsVerifyAPIKey(key).then(result => { if (result.success) { // \u9a8c\u8bc1\u6210\u529f,\u4fdd\u5b58key localStorage.setItem('GPTJsSetting.key', key); localStorage.setItem('tiku_key', key); saveKeyMsg.innerText = 'API Key \u4fdd\u5b58\u6210\u529f!'; saveKeyMsg.style.backgroundColor = '#4CAF50'; logger('API Key \u4fdd\u5b58\u6210\u529f!', 'green'); } else { // \u9a8c\u8bc1\u5931\u8d25 saveKeyMsg.innerText = 'Key\u4e0d\u5b58\u5728,\u8bf7\u524d\u5f80\u871c\u96ea\u6fc0\u6d3b'; saveKeyMsg.style.backgroundColor = '#f44336'; logger('Key\u4e0d\u5b58\u5728,\u8bf7\u524d\u5f80\u871c\u96ea\u6fc0\u6d3b', 'red'); } }).catch(error => { saveKeyMsg.innerText = '\u9a8c\u8bc1\u5931\u8d25: ' + error; saveKeyMsg.style.backgroundColor = '#f44336'; logger('Key\u9a8c\u8bc1\u51fa\u9519: ' + error, 'red'); }).finally(() => { saveKeyBtn.disabled = false; saveKeyBtn.innerText = '\u4fdd\u5b58\u9a8c\u8bc1'; setTimeout(() => { saveKeyMsg.style.display = 'none'; }, 3000); }); }); } // \u6700\u5c0f\u5316\u6309\u94ae const minimizeBtn = document.getElementById('zhs-minimize-btn'); const panelContent = document.getElementById('zhs-panel-content'); if (minimizeBtn && panelContent) { minimizeBtn.addEventListener('click', () => { const isMinimized = panelContent.style.display === 'none'; panelContent.style.display = isMinimized ? 'block' : 'none'; minimizeBtn.textContent = isMinimized ? '−' : '+'; }); } // \u5173\u95ed\u6309\u94ae const closeBtn = document.getElementById('zhs-close-btn'); if (closeBtn) { closeBtn.addEventListener('click', () => { const panel = document.getElementById('zhs-control-panel'); if (panel) { panel.style.display = 'none'; } }); } // \u7ed1\u5b9a\u66f4\u591a\u8bbe\u7f6e\u533a\u57df\u7684\u4e8b\u4ef6\u76d1\u542c\u5668 bindMoreSettingsEventListeners(); } // \u7ed1\u5b9a\u66f4\u591a\u8bbe\u7f6e\u533a\u57df\u7684\u4e8b\u4ef6\u76d1\u542c\u5668 - \u4fee\u590d\u8bbe\u7f6e\u6301\u4e45\u5316\u95ee\u9898 function bindMoreSettingsEventListeners() { // \u9898\u5e93\u7b54\u9898\u5f00\u5173 - \u4fee\u590d\u529f\u80fd\u5f00\u5173\u65e0\u6548\u95ee\u9898 const useTikuCheckbox = document.getElementById('GPTJsSetting.useTiku'); if (useTikuCheckbox) { // \u8bbe\u7f6e\u521d\u59cb\u72b6\u6001 - \u4fee\u590d\u9ed8\u8ba4\u72b6\u6001 useTikuCheckbox.checked = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; useTikuCheckbox.addEventListener('change', (e) => { const isChecked = e.target.checked; localStorage.setItem('GPTJsSetting.useTiku', isChecked.toString()); localStorage.setItem('ZhsJsSetting.useTiku', isChecked.toString()); setting.useTiku = isChecked; logger(`\u9898\u5e93\u7b54\u9898\u5df2${isChecked ? '\u5f00\u542f' : '\u5173\u95ed'}`, isChecked ? 'green' : 'orange'); }); } // AI\u81ea\u52a8\u7b54\u9898\u5f00\u5173 const useAICheckbox = document.getElementById('GPTJsSetting.useAI'); if (useAICheckbox) { // \u8bbe\u7f6e\u521d\u59cb\u72b6\u6001 useAICheckbox.checked = localStorage.getItem('GPTJsSetting.useAI') === 'true'; useAICheckbox.addEventListener('change', (e) => { const isChecked = e.target.checked; localStorage.setItem('GPTJsSetting.useAI', isChecked.toString()); localStorage.setItem('ZhsJsSetting.useAI', isChecked.toString()); setting.useAI = isChecked; logger(`AI\u81ea\u52a8\u7b54\u9898\u5df2${isChecked ? '\u5f00\u542f' : '\u5173\u95ed'}`, isChecked ? 'green' : 'orange'); }); } // \u81ea\u52a8\u63d0\u4ea4\u5f00\u5173 const autoSubmitCheckbox = document.getElementById('GPTJsSetting.autoSubmit'); if (autoSubmitCheckbox) { // \u8bbe\u7f6e\u521d\u59cb\u72b6\u6001 autoSubmitCheckbox.checked = localStorage.getItem('GPTJsSetting.autoSubmit') === 'true'; autoSubmitCheckbox.addEventListener('change', (e) => { const isChecked = e.target.checked; localStorage.setItem('GPTJsSetting.autoSubmit', isChecked.toString()); localStorage.setItem('ZhsJsSetting.autoSubmit', isChecked.toString()); setting.autoSubmit = isChecked; logger(`\u81ea\u52a8\u63d0\u4ea4\u5df2${isChecked ? '\u5f00\u542f' : '\u5173\u95ed'}`, isChecked ? 'green' : 'orange'); }); } // \u663e\u793a\u7b54\u6848\u5f00\u5173 const showAnswerCheckbox = document.getElementById('GPTJsSetting.showAnswer'); if (showAnswerCheckbox) { // \u8bbe\u7f6e\u521d\u59cb\u72b6\u6001 showAnswerCheckbox.checked = localStorage.getItem('GPTJsSetting.showAnswer') !== 'false'; showAnswerCheckbox.addEventListener('change', (e) => { const isChecked = e.target.checked; localStorage.setItem('GPTJsSetting.showAnswer', isChecked.toString()); localStorage.setItem('ZhsJsSetting.showAnswer', isChecked.toString()); setting.showAnswer = isChecked; logger(`\u663e\u793a\u7b54\u6848\u5df2${isChecked ? '\u5f00\u542f' : '\u5173\u95ed'}`, isChecked ? 'green' : 'orange'); }); } // AI\u6a21\u578b\u9009\u62e9 const modelSelect = document.getElementById('GPTJsSetting.model'); if (modelSelect) { // \u8bbe\u7f6e\u521d\u59cb\u72b6\u6001 const savedModel = localStorage.getItem('GPTJsSetting.model') || 'gpt-3.5-turbo-16k'; modelSelect.value = savedModel; modelSelect.addEventListener('change', (e) => { const selectedModel = e.target.value; localStorage.setItem('GPTJsSetting.model', selectedModel); localStorage.setItem('ZhsJsSetting.model', selectedModel); setting.model = selectedModel; logger(`AI\u6a21\u578b\u5df2\u5207\u6362\u4e3a: ${selectedModel}`, 'blue'); }); } logger('\u66f4\u591a\u8bbe\u7f6e\u533a\u57df\u4e8b\u4ef6\u76d1\u542c\u5668\u7ed1\u5b9a\u5b8c\u6210', 'blue'); } // \u66f4\u65b0\u5f00\u5173\u6837\u5f0f function updateToggleStyle(toggle) { const slider = toggle.nextElementSibling; const knob = slider.querySelector('span'); if (toggle.checked) { slider.style.backgroundColor = '#4CAF50'; knob.style.left = '29px'; } else { slider.style.backgroundColor = '#ccc'; knob.style.left = '3px'; } } // \u9ad8\u6027\u80fd\u62d6\u62fd\u529f\u80fd - \u57fa\u4e8exxt.js\u7684\u4f18\u5316\u5b9e\u73b0 function makeZhihuishuPanelDraggable(panel) { let isDragging = false; let dragOffsetX, dragOffsetY; // \u4fdd\u5b58\u4f4d\u7f6e\u5230localStorage function savePosition() { if (panel) { const rect = panel.getBoundingClientRect(); const position = { left: rect.left, top: rect.top }; localStorage.setItem('zhs-panel-position', JSON.stringify(position)); } } // \u4ecelocalStorage\u6062\u590d\u4f4d\u7f6e function loadPosition() { if (panel) { try { const savedPosition = localStorage.getItem('zhs-panel-position'); if (savedPosition) { const position = JSON.parse(savedPosition); panel.style.setProperty('left', position.left + 'px', 'important'); panel.style.setProperty('top', position.top + 'px', 'important'); panel.style.setProperty('right', 'auto', 'important'); } } catch (err) { // console.error('\u65e0\u6cd5\u6062\u590d\u9762\u677f\u4f4d\u7f6e', err); } } } // \u4f7f\u7528\u4e8b\u4ef6\u6355\u83b7\u9636\u6bb5,\u786e\u4fdd\u5148\u6355\u83b7\u4e8b\u4ef6 - \u5b8c\u5168\u4fee\u590dAI\u52a9\u624b\u9762\u677f\u4e8b\u4ef6\u51b2\u7a81\u95ee\u9898 panel.addEventListener('mousedown', function (e) { // \u5b8c\u5168\u7981\u6b62\u5728AI\u52a9\u624b\u9762\u677f\u5185\u62d6\u62fd if (e.target.closest('#zhs-tab-ai')) { e.stopPropagation(); return false; } // \u5b8c\u5168\u7981\u6b62\u5728\u6807\u7b7e\u5185\u5bb9\u533a\u57df\u62d6\u62fd if (e.target.closest('.zhs-tab-content')) { e.stopPropagation(); return false; } // \u6269\u5c55\u4ea4\u4e92\u5143\u7d20\u68c0\u6d4b - \u786e\u4fdd\u6240\u6709\u53ef\u4ea4\u4e92\u5143\u7d20\u90fd\u4e0d\u89e6\u53d1\u62d6\u52a8 const interactiveElements = ['BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'OPTION', 'A', 'LABEL']; // \u68c0\u67e5\u5143\u7d20\u6807\u7b7e if (interactiveElements.includes(e.target.tagName)) { e.stopPropagation(); return false; } // \u68c0\u67e5\u662f\u5426\u70b9\u51fb\u4e86\u4ea4\u4e92\u5143\u7d20\u7684\u5b50\u5143\u7d20 for (const tag of interactiveElements) { if (e.target.closest(tag.toLowerCase())) { e.stopPropagation(); return false; } } // \u53ea\u6709\u70b9\u51fb\u6807\u9898\u680f\u624d\u5141\u8bb8\u62d6\u52a8 const header = panel.querySelector('.gpt-box-header'); if (!header || (!header.contains(e.target) && !e.target.classList.contains('gpt-box-header'))) { return false; } isDragging = true; dragOffsetX = e.clientX - panel.getBoundingClientRect().left; dragOffsetY = e.clientY - panel.getBoundingClientRect().top; // \u62d6\u52a8\u65f6\u7981\u7528\u8fc7\u6e21\u6548\u679c - \u5173\u952e\u4f18\u5316\u70b9 panel.style.setProperty('transition', 'none', 'important'); // \u786e\u4fdd\u62d6\u52a8\u65f6\u9762\u677f\u5728\u6700\u9876\u5c42 panel.style.setProperty('z-index', '2147483647', 'important'); // \u62d6\u52a8\u65f6\u6539\u53d8\u89c6\u89c9\u6548\u679c panel.style.setProperty('box-shadow', '0 12px 48px rgba(0, 0, 0, 0.4)', 'important'); panel.style.setProperty('opacity', '0.95', 'important'); // \u9632\u6b62\u9009\u4e2d\u6587\u672c - \u53ea\u5728\u786e\u5b9e\u9700\u8981\u62d6\u52a8\u65f6\u624d\u963b\u6b62\u4e8b\u4ef6 e.preventDefault(); e.stopPropagation(); }, true); // \u4f7f\u7528\u9876\u5c42\u6587\u6863\u7684mousemove\u4e8b\u4ef6 - \u4f18\u5316\u6027\u80fd,\u4f7f\u7528requestAnimationFrame let animationId = null; document.addEventListener('mousemove', function (e) { if (isDragging) { // \u53d6\u6d88\u4e4b\u524d\u7684\u52a8\u753b\u5e27 if (animationId) { cancelAnimationFrame(animationId); } // \u4f7f\u7528requestAnimationFrame\u4f18\u5316\u62d6\u62fd\u6027\u80fd animationId = requestAnimationFrame(() => { const newLeft = e.clientX - dragOffsetX; const newTop = e.clientY - dragOffsetY; // \u786e\u4fdd\u4e0d\u8d85\u51fa\u5c4f\u5e55\u8fb9\u754c const maxX = window.innerWidth - panel.offsetWidth; const maxY = window.innerHeight - panel.offsetHeight; // \u4f7f\u7528!important\u786e\u4fdd\u6837\u5f0f\u4e0d\u88ab\u8986\u76d6 - \u5173\u952e\u4f18\u5316\u70b9 panel.style.setProperty('left', Math.max(0, Math.min(newLeft, maxX)) + 'px', 'important'); panel.style.setProperty('top', Math.max(0, Math.min(newTop, maxY)) + 'px', 'important'); panel.style.setProperty('right', 'auto', 'important'); panel.style.setProperty('bottom', 'auto', 'important'); }); // \u9632\u6b62\u4e8b\u4ef6\u4f20\u64ad e.preventDefault(); } }, true); document.addEventListener('mouseup', function (e) { if (isDragging) { isDragging = false; // \u6062\u590d\u8fc7\u6e21\u6548\u679c\u548c\u89c6\u89c9\u6837\u5f0f - \u5173\u952e\u4f18\u5316\u70b9 panel.style.setProperty('transition', 'all 0.3s ease', 'important'); panel.style.setProperty('box-shadow', '0 4px 12px rgba(0, 0, 0, 0.15)', 'important'); panel.style.setProperty('opacity', '1', 'important'); // \u9632\u6b62\u4e8b\u4ef6\u4f20\u64ad e.stopPropagation(); // \u4fdd\u5b58\u4f4d\u7f6e\u5230localStorage savePosition(); } }, true); // \u9875\u9762\u52a0\u8f7d\u65f6\u6062\u590d\u4f4d\u7f6e setTimeout(loadPosition, 1000); } // \u4f7f\u667a\u6167\u6811\u65e5\u5fd7\u7a97\u53e3\u53ef\u62d6\u62fd - \u4f18\u5316\u6027\u80fd,\u4fee\u590d\u5361\u987f\u95ee\u9898 function makeZhihuishuLogWindowDraggable(logWindow) { let isDragging = false; let currentX = 0; let currentY = 0; let initialX = 0; let initialY = 0; let xOffset = 0; let yOffset = 0; let animationId = null; const header = logWindow.querySelector('div:first-child'); header.style.cursor = 'move'; header.style.userSelect = 'none'; // \u9632\u6b62\u6587\u672c\u9009\u62e9 // \u4f18\u5316\u4e8b\u4ef6\u76d1\u542c\u5668 header.addEventListener('mousedown', dragStart, { passive: false }); function dragStart(e) { // \u6392\u9664\u6309\u94ae\u548c\u5176\u4ed6\u4ea4\u4e92\u5143\u7d20 if (e.target.tagName === 'BUTTON' || e.target.closest('button')) { return; } e.preventDefault(); e.stopPropagation(); initialX = e.clientX - xOffset; initialY = e.clientY - yOffset; isDragging = true; // \u6dfb\u52a0\u5168\u5c40\u4e8b\u4ef6\u76d1\u542c\u5668 document.addEventListener('mousemove', dragMove, { passive: false }); document.addEventListener('mouseup', dragEnd, { passive: false }); // \u6dfb\u52a0\u89c6\u89c9\u53cd\u9988 logWindow.style.opacity = '0.8'; logWindow.style.zIndex = '2147483647'; } function dragMove(e) { if (!isDragging) return; e.preventDefault(); // \u4f7f\u7528requestAnimationFrame\u4f18\u5316\u6027\u80fd if (animationId) { cancelAnimationFrame(animationId); } animationId = requestAnimationFrame(() => { currentX = e.clientX - initialX; currentY = e.clientY - initialY; xOffset = currentX; yOffset = currentY; // \u4f7f\u7528transform3d\u542f\u7528\u786c\u4ef6\u52a0\u901f logWindow.style.transform = `translate3d(${currentX}px, ${currentY}px, 0)`; }); } function dragEnd() { if (!isDragging) return; isDragging = false; // \u79fb\u9664\u5168\u5c40\u4e8b\u4ef6\u76d1\u542c\u5668 document.removeEventListener('mousemove', dragMove); document.removeEventListener('mouseup', dragEnd); // \u6062\u590d\u89c6\u89c9\u72b6\u6001 logWindow.style.opacity = '1'; logWindow.style.zIndex = '2147483645'; // \u6e05\u7406\u52a8\u753b\u5e27 if (animationId) { cancelAnimationFrame(animationId); animationId = null; } } } // \u6dfb\u52a0\u667a\u6167\u6811\u952e\u76d8\u5feb\u6377\u952e function addZhihuishuKeyboardShortcuts() { document.addEventListener('keydown', (e) => { // F9 \u663e\u793a/\u9690\u85cf\u63a7\u5236\u9762\u677f if (e.key === 'F9' || e.keyCode === 120) { e.preventDefault(); const panel = document.getElementById('zhs-control-panel'); if (panel) { panel.style.display = panel.style.display === 'none' ? 'block' : 'none'; logger(`\u63a7\u5236\u9762\u677f\u5df2${panel.style.display === 'none' ? '\u9690\u85cf' : '\u663e\u793a'}`, 'blue'); } } // F10 \u663e\u793a/\u9690\u85cf\u65e5\u5fd7\u7a97\u53e3 if (e.key === 'F10' || e.keyCode === 121) { e.preventDefault(); const logWindow = document.getElementById('zhs-log-window'); if (logWindow) { logWindow.style.display = logWindow.style.display === 'none' ? 'block' : 'none'; logger(`\u65e5\u5fd7\u7a97\u53e3\u5df2${logWindow.style.display === 'none' ? '\u9690\u85cf' : '\u663e\u793a'}`, 'blue'); } } // Ctrl+Shift+S \u5f00\u59cb\u7b54\u9898 if (e.ctrlKey && e.shiftKey && e.key === 'S') { e.preventDefault(); logger('\u5feb\u6377\u952e\u542f\u52a8\u7b54\u9898', 'green'); initZhihuishuExam(); } }); } // \u667a\u6167\u6811\u539f\u59cb\u7b54\u9898\u7cfb\u7edf\u521d\u59cb\u5316 function initZhihuishuOriginalAnswering() { logger('\u521d\u59cb\u5316\u667a\u6167\u6811\u539f\u59cb\u7b54\u9898\u7cfb\u7edf', 'blue'); // \u521d\u59cb\u5316\u961f\u5217\u548c\u53d8\u91cf setting.queue = setting.queue || []; setting.curs = setting.curs || []; setting.type = { \u5355\u9009\u9898: 1, \u591a\u9009\u9898: 2, \u586b\u7a7a\u9898: 3, \u95ee\u7b54\u9898: 4, '\u5206\u6790\u9898/\u89e3\u7b54\u9898/\u8ba1\u7b97\u9898/\u8bc1\u660e\u9898': 5, '\u9605\u8bfb\u7406\u89e3\uff08\u9009\u62e9\uff09/\u5b8c\u578b\u586b\u7a7a': 9, \u5224\u65ad\u9898: 14 }; setting.lose = setting.num = setting.small = 0; // \u8bbe\u7f6e\u6b63\u786e\u7684XMLHttpRequest\u94a9\u5b50(\u7528\u4e8e\u8003\u8bd5\u9875\u9762\u548c\u7ec3\u4e60\u9875\u9762) _self.XMLHttpRequest = function () { var ajax = new XMLHttpRequest(); ajax.onload = function (e) { // \u5904\u7406\u8003\u8bd5\u6570\u636e if (this.status == 200 && this.responseURL.match(/doHomework|doExam/)) { try { var obj = JSON.parse(this.responseText); if (obj.rt && obj.rt.examBase) { logger('\u83b7\u53d6\u5230\u8003\u8bd5\u6570\u636e\uff0c\u5f00\u59cb\u5904\u7406\u9898\u76ee', 'green'); zhsCollectData(obj.rt.examBase); } } catch (e) { logger('\u89e3\u6790\u8003\u8bd5\u6570\u636e\u5931\u8d25: ' + e, 'red'); } } // \u5904\u7406\u667a\u6167\u6811\u7ec3\u4e60\u9875\u9762\u7684\u9898\u76ee\u6570\u636e if (this.status == 200 && this.responseURL.match('getDoQuestSingle')) { // \u4e25\u683c\u68c0\u67e5API Key - \u8fd9\u662f\u7b2c\u4e8c\u4e2aAPI\u62e6\u622a\u9a8c\u8bc1\u70b9 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u6709\u6548\u7684key\uff0c\u4e14\u5f00\u542f\u4e86\u9700\u8981key\u7684\u529f\u80fd\uff0c\u5219\u4e0d\u5904\u7406API\u54cd\u5e94 if (!userKey || userKey.trim() === '' || userKey === '1') { if (useAI || useTiku) { logger('\u274c Key\u4e0d\u5b58\u5728\u6216\u65e0\u6548\uff0c\u8df3\u8fc7\u7ec3\u4e60\u9898\u76eeAPI\u62e6\u622a\u5904\u7406', 'red'); return; // \u5b8c\u5168\u505c\u6b62API\u62e6\u622a\u5904\u7406 } } try { var obj = JSON.parse(this.responseText).rt; logger('\u62e6\u622a\u5230\u667a\u6167\u6811\u9898\u76eeAPI\u54cd\u5e94', 'green'); logger(`\u9898\u76eeID: ${obj.questionId}`, 'blue'); logger(`\u9898\u76ee\u7c7b\u578b: ${obj.questionName} (ID: ${obj.questionTypeId})`, 'blue'); // \u5904\u7406\u9898\u76ee\u5185\u5bb9 if (obj.content) { var questionText = obj.content.replace(/<[^>]*>/g, '').trim(); logger(`\u9898\u76ee\u5185\u5bb9: ${questionText.substring(0, 100)}...`, 'blue'); // \u8c03\u7528\u9898\u5e93API\u83b7\u53d6\u7b54\u6848 zhsGetAnswerFromAPI(questionText, obj.questionTypeId, obj.questionOptionList); } } catch (e) { logger('\u5904\u7406\u667a\u6167\u6811API\u54cd\u5e94\u65f6\u51fa\u9519: ' + e.message, 'red'); } } }; return ajax; }; // \u542f\u52a8\u7b54\u9898\u961f\u5217\u5904\u7406 setInterval(function () { if (setting.queue.length > 0) { const element = setting.queue.shift(); if (element && element.parentElement) { element.parentElement.click(); logger('\u70b9\u51fb\u961f\u5217\u4e2d\u7684\u9009\u9879', 'blue'); } } }, 1000); // \u7981\u7528\u65e7\u7684\u7b54\u9898\u5faa\u73af\uff0c\u4f7f\u7528\u65b0\u7684zhsProcessQuestions\u7cfb\u7edf // setting.loop = setInterval(zhsFindAnswer, setting.time, true); logger('\u667a\u6167\u6811\u7b54\u9898\u7cfb\u7edf\u521d\u59cb\u5316\u5b8c\u6210', 'green'); } // \u667a\u6167\u6811\u6536\u96c6\u8003\u8bd5\u6570\u636e function zhsCollectData(examBase) { logger('\u5f00\u59cb\u6536\u96c6\u667a\u6167\u6811\u8003\u8bd5\u6570\u636e', 'blue'); // \u5b58\u50a8\u8003\u8bd5\u57fa\u7840\u4fe1\u606f setting.examBase = examBase; setting.curs = []; // \u83b7\u53d6\u8bfe\u7a0b\u4fe1\u606f $('.infoList span').each(function () { setting.curs.push($(this).text().trim()); }); logger(`\u6536\u96c6\u5230\u8bfe\u7a0b\u4fe1\u606f: ${setting.curs.length} \u9879`, 'blue'); logger('\u8003\u8bd5\u6570\u636e\u6536\u96c6\u5b8c\u6210\uff0c\u5f00\u59cb\u7b54\u9898\u6d41\u7a0b', 'green'); } // \u68c0\u67e5\u662f\u5426\u4e3a\u667a\u6167\u6811\u7b54\u9898\u9875\u9762 - \u4fee\u590d\u89c6\u9891\u9875\u9762\u8bef\u8bc6\u522b\u95ee\u9898 function checkZhsAnswerPage() { // \u9996\u5148\u6392\u9664\u89c6\u9891\u9875\u9762 const url = window.location.href; const isVideoPage = url.includes('hike.zhihuishu.com') || url.includes('sourceLearning') || url.includes('videoList'); if (isVideoPage) { logger('\u68c0\u6d4b\u5230\u89c6\u9891\u9875\u9762\uff0c\u4e0d\u542f\u52a8\u7b54\u9898\u529f\u80fd', 'blue'); return false; } // \u68c0\u67e5URL\u7279\u5f81 - \u53ea\u68c0\u67e5\u660e\u786e\u7684\u7b54\u9898\u9875\u9762 const isZhsExamUrl = url.includes('zhihuishu.com') && (url.includes('hiexam') || url.includes('homework') || url.includes('test') || url.includes('exam')); // \u68c0\u67e5\u9875\u9762\u5143\u7d20\u7279\u5f81 - \u667a\u6167\u6811\u7b54\u9898\u9875\u9762\u7684\u7279\u6709\u5143\u7d20 const hasZhsElements = $('.answerCard').length > 0 || // \u7b54\u9898\u5361 $('.optionUl').length > 0 || // \u9009\u9879\u5217\u8868 $('.subject_stem').length > 0 || // \u9898\u76ee\u4e3b\u4f53 $('.examPaper_subject').length > 0 || // \u8003\u8bd5\u9898\u76ee $('.TiMu').length > 0 || // \u9898\u76ee\u5bb9\u5668 $('[class*="option"]').length > 0 || // \u9009\u9879\u5143\u7d20 $('[class*="question"]').length > 0; // \u9898\u76ee\u5143\u7d20 // \u68c0\u67e5\u9875\u9762\u6807\u9898 - \u66f4\u7cbe\u786e\u7684\u6807\u9898\u68c0\u6d4b const hasZhsTitle = (document.title.includes('\u667a\u6167\u6811') && (document.title.includes('\u8003\u8bd5') || document.title.includes('\u4f5c\u4e1a'))) || document.title.includes('\u7b54\u9898'); const isAnswerPage = isZhsExamUrl || (hasZhsElements && hasZhsTitle); if (isAnswerPage) { logger('\u68c0\u6d4b\u5230\u667a\u6167\u6811\u7b54\u9898\u9875\u9762,\u9875\u9762\u9a8c\u8bc1\u901a\u8fc7', 'green'); } else { logger('\u9875\u9762\u68c0\u6d4b\u7ed3\u679c:URL=' + isZhsExamUrl + ', \u5143\u7d20=' + hasZhsElements + ', \u6807\u9898=' + hasZhsTitle, 'blue'); } return isAnswerPage; } // \u5168\u5c40\u505c\u6b62\u6240\u6709\u81ea\u52a8\u5316\u64cd\u4f5c\u51fd\u6570 function zhsStopAllAutoActions() { // \u505c\u6b62\u81ea\u52a8\u7b54\u9898 setting.work = 0; localStorage.setItem('GPTJsSetting.work', 'false'); logger('🛑 \u505c\u6b62\u81ea\u52a8\u7b54\u9898', 'red'); // \u6e05\u9664\u6240\u6709\u7b54\u9898\u76f8\u5173\u7684\u5b9a\u65f6\u5668 if (setting.loop) { clearInterval(setting.loop); setting.loop = null; logger('🛑 \u5df2\u6e05\u9664\u7b54\u9898\u5b9a\u65f6\u5668', 'blue'); } // \u6e05\u7a7a\u7b54\u9898\u961f\u5217 setting.queue = []; logger('🛑 \u5df2\u6e05\u7a7a\u7b54\u9898\u961f\u5217', 'blue'); // \u6e05\u9664\u53ef\u80fd\u5b58\u5728\u7684\u5176\u4ed6\u5b9a\u65f6\u5668 if (window.zhsNavigationTimer) { clearTimeout(window.zhsNavigationTimer); window.zhsNavigationTimer = null; logger('🛑 \u5df2\u6e05\u9664\u5bfc\u822a\u5b9a\u65f6\u5668', 'blue'); } // \u505c\u6b62\u6240\u6709\u81ea\u52a8\u5bfc\u822a\u884c\u4e3a logger('🛑 \u5df2\u505c\u6b62\u6240\u6709\u81ea\u52a8\u5bfc\u822a\u884c\u4e3a', 'blue'); // \u63d0\u793a\u7528\u6237 logger('✅ \u6240\u6709\u81ea\u52a8\u5316\u64cd\u4f5c\u5df2\u505c\u6b62,\u53ef\u624b\u52a8\u64cd\u4f5c', 'green'); } // \u667a\u6167\u6811\u4e13\u7528\u9898\u76ee\u5904\u7406\u903b\u8f91 - \u57fa\u4e8exxt.js\u67b6\u6784,\u589e\u52a0\u4e25\u683c\u7684Key\u9a8c\u8bc1 function zhsProcessQuestions() { logger('🚀 \u542f\u52a8\u667a\u6167\u6811\u4e13\u7528\u9898\u76ee\u5904\u7406\u903b\u8f91', 'green'); // \u4e25\u683c\u68c0\u67e5API Key - \u4fee\u590d\u7528\u6237\u53cd\u9988\u7684\u65e0key\u4e5f\u80fd\u7b54\u9898\u7684\u95ee\u9898 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u6709\u6548\u7684key,\u4e14\u5f00\u542f\u4e86\u9700\u8981key\u7684\u529f\u80fd,\u5219\u505c\u6b62\u7b54\u9898 if (!userKey || userKey.trim() === '' || userKey === '1') { if (useAI || useTiku) { logger('❌ Key\u4e0d\u5b58\u5728\u6216\u65e0\u6548,\u8bf7\u524d\u5f80\u871c\u96ea\u6fc0\u6d3b', 'red'); logger('💡 \u8bf7\u5728\u8bbe\u7f6e\u4e2d\u914d\u7f6e\u6709\u6548\u7684API Key\u540e\u518d\u5f00\u59cb\u7b54\u9898', 'orange'); // \u663e\u793aKey\u914d\u7f6e\u63d0\u793a const controlPanel = document.getElementById('zhs-control-panel'); if (controlPanel) { const keyTip = controlPanel.querySelector('.zhs-key-tip') || document.createElement('div'); keyTip.className = 'zhs-key-tip'; keyTip.style.cssText = ` background: #fff2f0; border: 1px solid #ffccc7; color: #ff4d4f; padding: 8px; margin: 8px 0; border-radius: 4px; font-size: 12px; `; keyTip.innerHTML = '⚠️ Key\u4e0d\u5b58\u5728,\u8bf7\u524d\u5f80 \u871c\u96ea\u6fc0\u6d3b'; if (!controlPanel.querySelector('.zhs-key-tip')) { controlPanel.appendChild(keyTip); } } return; // \u505c\u6b62\u6267\u884c,\u4e0d\u8fdb\u884c\u4efb\u4f55\u7b54\u9898\u64cd\u4f5c } } logger('\u81ea\u52a8\u7b54\u9898\u529f\u80fd\u5df2\u542f\u7528,\u5f00\u59cb\u5904\u7406\u9898\u76ee', 'green'); // \u57fa\u4e8e\u5b9e\u9645DOM\u7ed3\u6784\u67e5\u627e\u9898\u76ee\u5143\u7d20 - \u53c2\u8003xxt.js\u6a21\u5f0f let questionElements = []; // \u667a\u6167\u6811\u9875\u9762\u7684\u5b9e\u9645\u7ed3\u6784:\u67e5\u627e\u5305\u542b\u9009\u9879\u7684\u5bb9\u5668 // \u67e5\u627e.optionUl\u5bb9\u5668,\u8fd9\u662f\u667a\u6167\u6811\u9009\u9879\u7684\u6807\u51c6\u5bb9\u5668 const optionContainers = $('.optionUl'); if (optionContainers.length > 0) { // \u4ece\u9009\u9879\u5bb9\u5668\u5411\u4e0a\u67e5\u627e\u5305\u542b\u9898\u76ee\u7684\u5b8c\u6574\u5bb9\u5668 const questionContainer = optionContainers.first().closest('div, section, article').first(); if (questionContainer.length > 0) { questionElements = [questionContainer]; logger(`\u627e\u5230 ${questionElements.length} \u4e2a\u667a\u6167\u6811\u9898\u76ee\u5bb9\u5668(\u57fa\u4e8eoptionUl)`, 'green'); } } // \u5907\u7528\u65b9\u68481:\u68c0\u67e5.TiMu\u5143\u7d20(\u5176\u4ed6\u667a\u6167\u6811\u9875\u9762) else if ($('.TiMu').length > 0) { questionElements = $('.TiMu'); logger(`\u627e\u5230 ${questionElements.length} \u4e2a.TiMu\u9898\u76ee\u5143\u7d20`, 'green'); } // \u5907\u7528\u65b9\u68482:\u68c0\u67e5.examPaper_subject\u5143\u7d20 else if ($('.examPaper_subject').length > 0) { questionElements = $('.examPaper_subject'); logger(`\u627e\u5230 ${questionElements.length} \u4e2a.examPaper_subject\u9898\u76ee\u5143\u7d20`, 'green'); } // \u5907\u7528\u65b9\u68483:\u68c0\u67e5\u5176\u4ed6\u53ef\u80fd\u7684\u9898\u76ee\u5bb9\u5668 else if ($('[class*="question"]').length > 0) { questionElements = $('[class*="question"]'); logger(`\u627e\u5230 ${questionElements.length} \u4e2aquestion\u76f8\u5173\u9898\u76ee\u5143\u7d20`, 'green'); } else { logger('❌ \u672a\u627e\u5230\u4efb\u4f55\u9898\u76ee\u5143\u7d20,\u505c\u6b62\u7b54\u9898\u907f\u514d\u65e0\u9650\u5faa\u73af', 'red'); // \u4e0d\u518d\u91cd\u8bd5,\u907f\u514d\u65e0\u9650\u5faa\u73af return; } // \u5f00\u59cb\u5904\u7406\u9898\u76ee if (questionElements.length > 0) { logger(`✅ \u5f00\u59cb\u5904\u7406 ${questionElements.length} \u9053\u9898\u76ee`, 'green'); zhsProcessSingleQuestion(0, questionElements); } } // \u5904\u7406\u5355\u4e2a\u667a\u6167\u6811\u9898\u76ee - \u57fa\u4e8exxt.js\u67b6\u6784\u548c\u5b9e\u9645DOM\u7ed3\u6784 function zhsProcessSingleQuestion(index, questionElements) { // \u667a\u6167\u6811\u9875\u9762\u7279\u70b9:\u4e00\u6b21\u53ea\u663e\u793a\u4e00\u4e2a\u9898\u76ee,\u9700\u8981\u901a\u8fc7\u5bfc\u822a\u5207\u6362 // \u6240\u4ee5\u8fd9\u91cc\u7684\u903b\u8f91\u4e0exxt.js\u4e0d\u540c,\u6211\u4eec\u5904\u7406\u5f53\u524d\u663e\u793a\u7684\u9898\u76ee // \u4e25\u683c\u68c0\u67e5API Key - \u8fd9\u662f\u6700\u5173\u952e\u7684\u9a8c\u8bc1\u70b9,\u786e\u4fdd\u6ca1\u6709\u6709\u6548key\u65f6\u5b8c\u5168\u505c\u6b62 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u6709\u6548\u7684key,\u4e14\u5f00\u542f\u4e86\u9700\u8981key\u7684\u529f\u80fd,\u5219\u5b8c\u5168\u505c\u6b62 if (!userKey || userKey.trim() === '' || userKey === '1') { if (useAI || useTiku) { logger('❌ Key\u4e0d\u5b58\u5728\u6216\u65e0\u6548,\u505c\u6b62\u9898\u76ee\u5904\u7406', 'red'); logger('💡 \u8bf7\u914d\u7f6e\u6709\u6548\u7684API Key\u540e\u5237\u65b0\u9875\u9762', 'orange'); return; // \u5b8c\u5168\u505c\u6b62\u6267\u884c,\u4e0d\u8fdb\u884c\u4efb\u4f55\u9898\u76ee\u5904\u7406 } } // \u68c0\u67e5\u662f\u5426\u624b\u52a8\u505c\u6b62\u7b54\u9898 if (localStorage.getItem('GPTJsSetting.work') === 'false') { logger('\u7528\u6237\u624b\u52a8\u505c\u6b62\u7b54\u9898,\u8df3\u8fc7\u5f53\u524d\u9898\u76ee', 'red'); return; } // \u91cd\u65b0\u67e5\u627e\u5f53\u524d\u9875\u9762\u7684\u9898\u76ee(\u56e0\u4e3a\u5bfc\u822a\u540eDOM\u4f1a\u66f4\u65b0) const currentOptionContainer = $('.optionUl').first(); const currentQuestionContainer = currentOptionContainer.length > 0 ? currentOptionContainer.closest('div, section, article').first() : $(); if (currentQuestionContainer.length === 0) { logger('❌ \u672a\u627e\u5230\u5f53\u524d\u9898\u76ee\u5bb9\u5668,\u53ef\u80fd\u5df2\u5b8c\u6210\u6240\u6709\u9898\u76ee', 'red'); return; } logger(`📝 \u5f00\u59cb\u5904\u7406\u5f53\u524d\u9898\u76ee`, 'blue'); // \u63d0\u53d6\u9898\u76ee\u4fe1\u606f const questionData = zhsExtractQuestionData(currentQuestionContainer); if (!questionData.question || questionData.question.length < 10) { logger(`❌ \u9898\u76ee\u6570\u636e\u63d0\u53d6\u5931\u8d25\u6216\u5185\u5bb9\u8fc7\u77ed,\u5c1d\u8bd5\u91cd\u65b0\u63d0\u53d6`, 'red'); // \u5c1d\u8bd5\u4f7f\u7528\u66f4\u7b80\u5355\u7684\u65b9\u6cd5\u91cd\u65b0\u63d0\u53d6\u9898\u76ee\u5185\u5bb9 const fallbackQuestionText = getQuestionText(currentQuestionContainer); if (fallbackQuestionText && fallbackQuestionText.length > 10) { questionData.question = fallbackQuestionText; logger(`✅ \u4f7f\u7528\u5907\u7528\u65b9\u6cd5\u6210\u529f\u63d0\u53d6\u9898\u76ee: ${fallbackQuestionText.substring(0, 50)}...`, 'green'); } else { logger(`❌ \u5907\u7528\u65b9\u6cd5\u4e5f\u65e0\u6cd5\u63d0\u53d6\u9898\u76ee,\u8df3\u8fc7`, 'red'); // \u5c1d\u8bd5\u5bfc\u822a\u5230\u4e0b\u4e00\u9898 setTimeout(() => { if (zhsNavigateToNext()) { setTimeout(() => zhsProcessSingleQuestion(0, []), 3000); } }, 2000); return; } } // \u79fb\u9664\u5df2\u4f5c\u7b54\u68c0\u67e5 - \u6839\u636e\u7528\u6237\u8981\u6c42,\u603b\u662f\u91cd\u65b0\u7b54\u9898 // \u7528\u6237\u8981\u6c42:\u4e0d\u5224\u65ad\u5df2\u4f5c\u7b54\u7684,\u5c31\u7b97\u4f5c\u7b54\u4e86,\u8981\u4f1a\u91cd\u65b0\u7b54\u9898,\u6839\u636e\u83b7\u53d6\u7684\u7b54\u6848\u8fdb\u884c\u586b\u5145\u9009\u9879 // const radioGroupCheck = currentQuestionContainer.find('[role="radiogroup"]'); // const checkedRadio = radioGroupCheck.find('[role="radio"][aria-checked="true"]'); // if (checkedRadio.length > 0) { // logger(`✅ \u5f53\u524d\u9898\u76ee\u5df2\u4f5c\u7b54,\u5bfc\u822a\u5230\u4e0b\u4e00\u9898`, 'green'); // setTimeout(() => { // if (zhsNavigateToNext()) { // setTimeout(() => zhsProcessSingleQuestion(0, []), 3000); // } // }, 1000); // return; // } logger(`📝 \u5f00\u59cb\u91cd\u65b0\u5904\u7406\u9898\u76ee(\u5ffd\u7565\u5df2\u4f5c\u7b54\u72b6\u6001)`, 'blue'); // \u4f7f\u7528\u56db\u7ea7\u4f18\u5148\u7ea7\u83b7\u53d6\u7b54\u6848 zhsGetAnswerWithPriority(questionData).then(answer => { // \u68c0\u67e5\u662f\u5426\u624b\u52a8\u505c\u6b62\u7b54\u9898 if (localStorage.getItem('GPTJsSetting.work') === 'false') { logger('\u7528\u6237\u624b\u52a8\u505c\u6b62\u7b54\u9898,\u8df3\u8fc7\u7b54\u6848\u5904\u7406', 'red'); return; } if (answer) { logger(`✅ \u83b7\u53d6\u5230\u7b54\u6848: ${answer}`, 'green'); // \u9009\u62e9\u7b54\u6848 const success = zhsSelectAnswer(currentQuestionContainer, answer); if (success) { logger(`✅ \u9898\u76ee\u5904\u7406\u6210\u529f,\u51c6\u5907\u81ea\u52a8\u4e0b\u4e00\u9898`, 'green'); // \u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u8ba9\u9009\u62e9\u751f\u6548,\u7136\u540e\u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898 setTimeout(() => { if (localStorage.getItem('GPTJsSetting.work') === 'true') { const navigated = zhsNavigateToNext(); if (navigated) { logger(`🔄 \u5df2\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u9898`, 'blue'); // \u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u540e\u7ee7\u7eed\u5904\u7406\u4e0b\u4e00\u9898 setTimeout(() => { if (localStorage.getItem('GPTJsSetting.work') === 'true') { zhsProcessSingleQuestion(0, []); } }, 3000); } else { logger(`✅ \u5df2\u5b8c\u6210\u6240\u6709\u9898\u76ee\u6216\u5230\u8fbe\u6700\u540e\u4e00\u9898,\u505c\u6b62\u81ea\u52a8\u7b54\u9898`, 'green'); // \u505c\u6b62\u81ea\u52a8\u7b54\u9898,\u907f\u514d\u65e0\u9650\u5faa\u73af localStorage.setItem('GPTJsSetting.work', 'false'); } } }, 1500); } else { logger(`⚠️ \u7b54\u6848\u9009\u62e9\u5931\u8d25,\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u9898`, 'orange'); // \u5373\u4f7f\u7b54\u6848\u9009\u62e9\u5931\u8d25,\u4e5f\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u9898 setTimeout(() => { if (localStorage.getItem('GPTJsSetting.work') === 'true') { const navigated = zhsNavigateToNext(); if (navigated) { logger(`🔄 \u5df2\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u9898`, 'blue'); // \u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u540e\u7ee7\u7eed\u5904\u7406\u4e0b\u4e00\u9898 setTimeout(() => { if (localStorage.getItem('GPTJsSetting.work') === 'true') { zhsProcessSingleQuestion(0, []); } }, 3000); } else { logger(`✅ \u5df2\u5b8c\u6210\u6240\u6709\u9898\u76ee\u6216\u5230\u8fbe\u6700\u540e\u4e00\u9898,\u505c\u6b62\u81ea\u52a8\u7b54\u9898`, 'green'); localStorage.setItem('GPTJsSetting.work', 'false'); } } }, 1500); } } else { logger(`⚠️ \u672a\u83b7\u53d6\u5230\u7b54\u6848,\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u9898`, 'orange'); // \u5373\u4f7f\u672a\u83b7\u53d6\u5230\u7b54\u6848,\u4e5f\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u9898 setTimeout(() => { if (localStorage.getItem('GPTJsSetting.work') === 'true') { const navigated = zhsNavigateToNext(); if (navigated) { logger(`🔄 \u5df2\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u9898`, 'blue'); // \u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u540e\u7ee7\u7eed\u5904\u7406\u4e0b\u4e00\u9898 setTimeout(() => { if (localStorage.getItem('GPTJsSetting.work') === 'true') { zhsProcessSingleQuestion(0, []); } }, 3000); } else { logger(`✅ \u5df2\u5b8c\u6210\u6240\u6709\u9898\u76ee\u6216\u5230\u8fbe\u6700\u540e\u4e00\u9898,\u505c\u6b62\u81ea\u52a8\u7b54\u9898`, 'green'); localStorage.setItem('GPTJsSetting.work', 'false'); } } }, 1500); } }).catch(error => { logger(`❌ \u9898\u76ee\u5904\u7406\u51fa\u9519: ${error}`, 'red'); // \u5c1d\u8bd5\u5bfc\u822a\u5230\u4e0b\u4e00\u9898 setTimeout(() => { const navigated = zhsNavigateToNext(); if (navigated) { setTimeout(() => zhsProcessSingleQuestion(0, []), 3000); } else { logger(`❌ \u5bfc\u822a\u5931\u8d25,\u505c\u6b62\u81ea\u52a8\u7b54\u9898\u907f\u514d\u65e0\u9650\u5faa\u73af`, 'red'); localStorage.setItem('GPTJsSetting.work', 'false'); } }, 2000); }); } // \u6dfb\u52a0xxt.js\u7684\u8f85\u52a9\u51fd\u6570 function cleanTextContent(textString) { if (!textString) return null; // \u79fb\u9664HTML\u6807\u7b7e(\u4fdd\u7559img\u6807\u7b7e) let cleaned = textString.replace(/<(?!img).*?>/g, ""); // \u79fb\u9664\u591a\u4f59\u7684\u7a7a\u767d\u5b57\u7b26 cleaned = cleaned .replace(/\s+/g, ' ') .replace(/^\s+/, '') .replace(/\s+$/, ''); return cleaned; } function formatQuestionText(questionText) { if (!questionText) return null; // \u5148\u8fdb\u884c\u57fa\u7840\u6e05\u7406 let formatted = cleanTextContent(questionText); // \u989d\u5916\u5904\u7406\u9488\u5bf9\u95ee\u9898\u7279\u6709\u7684\u683c\u5f0f formatted = formatted .replace(/^\d+[\.、]/, '') // \u79fb\u9664\u9898\u53f7 .replace(/^\s*[\((【\[]?\s*(\u5355\u9009\u9898|\u591a\u9009\u9898|\u5224\u65ad\u9898|\u586b\u7a7a\u9898|\u7b80\u7b54\u9898|\u8bba\u8ff0\u9898|\u5206\u6790\u9898)[\s\.\::,,]*[\d\.]*\u5206?[\))\]\】]?\s*/i, '') // \u79fb\u9664\u9898\u76ee\u7c7b\u578b\u4fe1\u606f .replace(/\(\s*\d+\.\d+\s*\u5206\s*\)/g, '') // \u79fb\u9664\u5206\u6570\u4fe1\u606f .replace(/(\s*\d+\.\d+\s*\u5206\s*)/g, '') // \u79fb\u9664\u5206\u6570\u4fe1\u606f .trim(); return formatted; } // \u91cd\u65b0\u8bbe\u8ba1\u7684\u9898\u76ee\u6570\u636e\u63d0\u53d6\u51fd\u6570 - \u57fa\u4e8e\u5b9e\u9645DOM\u7ed3\u6784 function zhsExtractQuestionData(questionElement) { const questionData = { question: '', type: '', options: [], element: questionElement }; try { // \u8c03\u8bd5:\u8f93\u51fa\u9898\u76ee\u5bb9\u5668\u7684\u57fa\u672c\u4fe1\u606f // logger(`🔍 \u8c03\u8bd5:\u9898\u76ee\u5bb9\u5668HTML: ${questionElement.html().substring(0, 200)}...`, 'blue'); // 1. \u63d0\u53d6\u9898\u76ee\u7c7b\u578b - \u4f7f\u7528role\u5c5e\u6027\u548c\u6587\u672c\u5339\u914d const allElements = questionElement.find('*'); let questionType = ''; // logger(`🔍 \u8c03\u8bd5:\u627e\u5230 ${allElements.length} \u4e2a\u5b50\u5143\u7d20`, 'blue'); allElements.each(function (index) { const text = $(this).text().trim(); // \u67e5\u627e "1.【\u5355\u9009\u9898】 (0.5\u5206)" \u683c\u5f0f const typeMatch = text.match(/\d+\.\s*【(.+?)】.*?\(\d+\.?\d*\u5206\)/); if (typeMatch) { questionType = typeMatch[1]; // logger(`🔍 \u8c03\u8bd5:\u627e\u5230\u9898\u76ee\u7c7b\u578b: "${questionType}" \u5728\u5143\u7d20: ${$(this).prop('tagName')}`, 'green'); return false; // \u8df3\u51faeach\u5faa\u73af } }); questionData.type = questionType; // 2. \u63d0\u53d6\u7eaf\u51c0\u7684\u9898\u76ee\u5185\u5bb9 - \u4fee\u590d\u9898\u76ee\u5185\u5bb9\u83b7\u53d6\u9519\u8bef // \u4f18\u5148\u4ececlass="questionContent"\u4e0b\u7684p\u6807\u7b7e\u91cc\u7684span\u5185\u5bb9\u83b7\u53d6 let questionText = ''; // \u65b9\u6cd51:\u67e5\u627eclass="questionContent"\u4e0b\u7684p\u6807\u7b7e\u91cc\u7684span\u5185\u5bb9(\u7528\u6237\u8981\u6c42\u7684\u6b63\u786e\u65b9\u5f0f) const questionContentDiv = questionElement.find('.questionContent'); if (questionContentDiv.length > 0) { const spans = questionContentDiv.find('p span'); if (spans.length > 0) { // \u63d0\u53d6\u6240\u6709span\u7684\u6587\u672c\u5185\u5bb9\u5e76\u5408\u5e76,\u907f\u514d\u91cd\u590d let spanTexts = []; let seenTexts = new Set(); // \u7528\u4e8e\u53bb\u91cd spans.each(function () { const spanText = $(this).text().trim(); if (spanText && !spanText.match(/^[A-D]\./) && spanText.length > 0) { // \u907f\u514d\u91cd\u590d\u6dfb\u52a0\u76f8\u540c\u7684\u6587\u672c if (!seenTexts.has(spanText)) { spanTexts.push(spanText); seenTexts.add(spanText); } } }); questionText = spanTexts.join('').trim(); logger(`🔍 \u4ece.questionContent p span\u83b7\u53d6\u9898\u76ee\u5185\u5bb9: ${questionText.substring(0, 50)}...`, 'green'); } } // \u65b9\u6cd52:\u5982\u679c\u6ca1\u627e\u5230,\u5c1d\u8bd5\u67e5\u627ep\u6807\u7b7e,\u4f46\u6392\u9664\u9009\u9879\u533a\u57df\u5185\u7684p\u6807\u7b7e if (!questionText) { const paragraphs = questionElement.find('p').not('.optionUl p, .el-radio p'); paragraphs.each(function () { const text = $(this).text().trim(); // \u8df3\u8fc7\u9898\u76ee\u7c7b\u578b\u884c\u548c\u77ed\u6587\u672c,\u9009\u62e9\u6700\u53ef\u80fd\u7684\u9898\u76ee\u5185\u5bb9 if (!text.match(/^[\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341]、.*?\u9898/) && !text.match(/^[A-D]\./) && text.length > 10) { questionText = text; return false; // \u627e\u5230\u9898\u76ee\u5185\u5bb9\u540e\u8df3\u51fa } }); } // \u65b9\u6cd53:\u5982\u679c\u8fd8\u6ca1\u627e\u5230,\u5c1d\u8bd5\u67e5\u627e\u5176\u4ed6\u53ef\u80fd\u7684\u9898\u76ee\u5bb9\u5668 if (!questionText) { const questionSelectors = [ '.questionTit', // \u6dfb\u52a0\u5bf9questionTit\u7684\u652f\u6301(\u4f5c\u4e3a\u5907\u9009) '.question-text', '.subject_stem', '.question-content', '.stem', '.title' ]; for (const selector of questionSelectors) { const element = questionElement.find(selector).first(); if (element.length > 0) { questionText = element.text().trim(); break; } } } // \u65b9\u6cd54:\u5982\u679c\u4ecd\u7136\u6ca1\u627e\u5230,\u5c1d\u8bd5\u4ece\u6240\u6709\u6587\u672c\u4e2d\u63d0\u53d6\u9898\u76ee if (!questionText || questionText.length < 10) { const allText = questionElement.text(); // \u67e5\u627e\u9898\u76ee\u7f16\u53f7\u540e\u7684\u5185\u5bb9,\u5982"1.【\u5355\u9009\u9898】 (1\u5206) \u9898\u76ee\u5185\u5bb9" const questionMatch = allText.match(/\d+\.\s*【.+?】\s*\(.+?\)\s*(.+?)(?=\s*[A-D]\.|$)/); if (questionMatch && questionMatch[1]) { questionText = questionMatch[1].trim(); logger(`🔍 \u4ece\u5b8c\u6574\u6587\u672c\u4e2d\u63d0\u53d6\u9898\u76ee: ${questionText.substring(0, 50)}...`, 'green'); } } // \u6e05\u7406\u9898\u76ee\u6587\u672c(\u53c2\u8003xxt.js\u7684cleanTextContent) questionText = questionText .replace(/\s+/g, ' ') // \u5408\u5e76\u591a\u4e2a\u7a7a\u683c .trim(); questionData.question = questionText; // 3. \u63d0\u53d6\u9009\u9879 - \u57fa\u4e8e\u5b9e\u9645HTML\u7ed3\u6784 const optionContainer = questionElement.find('.optionUl'); // logger(`🔍 \u8c03\u8bd5:\u627e\u5230 ${optionContainer.length} \u4e2a.optionUl\u5bb9\u5668`, 'blue'); if (optionContainer.length > 0) { const radioGroup = optionContainer.find('[role="radiogroup"]'); // logger(`🔍 \u8c03\u8bd5:\u627e\u5230 ${radioGroup.length} \u4e2arole="radiogroup"`, 'blue'); if (radioGroup.length > 0) { const radioElements = radioGroup.find('[role="radio"]'); // logger(`🔍 \u8c03\u8bd5:\u627e\u5230 ${radioElements.length} \u4e2arole="radio"\u5143\u7d20`, 'blue'); radioElements.each(function (index) { // \u67e5\u627e.optionContent\u5143\u7d20,\u8fd9\u662f\u667a\u6167\u6811\u9009\u9879\u5185\u5bb9\u7684\u5b9e\u9645\u5bb9\u5668 const optionContent = $(this).find('.optionContent'); let optionText = ''; if (optionContent.length > 0) { optionText = optionContent.text().trim(); // logger(`🔍 \u8c03\u8bd5:radio[${index}] optionContent: "${optionText}"`, 'blue'); } else { // \u5907\u7528\u65b9\u6848:\u4eceel-radio__label\u4e2d\u63d0\u53d6\u6587\u672c const radioLabel = $(this).find('.el-radio__label'); if (radioLabel.length > 0) { optionText = radioLabel.text().trim(); // \u79fb\u9664\u9009\u9879\u5b57\u6bcd\u524d\u7f00(\u5982"A. ") optionText = optionText.replace(/^[A-Z]\.\s*/, '').trim(); // logger(`🔍 \u8c03\u8bd5:radio[${index}] radioLabel: "${optionText}"`, 'blue'); } } if (optionText && optionText.length > 0) { questionData.options.push(optionText); // logger(`🔍 \u8c03\u8bd5:\u6dfb\u52a0\u9009\u9879: "${optionText}"`, 'green'); } }); } } // 4. \u5982\u679c\u662f\u5224\u65ad\u9898\u4e14\u6ca1\u6709\u627e\u5230\u9009\u9879,\u6dfb\u52a0\u6807\u51c6\u9009\u9879(\u53c2\u8003xxt.js) if (questionData.type === '\u5224\u65ad\u9898' && questionData.options.length === 0) { questionData.options = ['\u6b63\u786e', '\u9519\u8bef']; } // 5. \u8bb0\u5f55\u63d0\u53d6\u7ed3\u679c(\u7b80\u5316\u65e5\u5fd7\u8f93\u51fa) logger(`📋 \u9898\u76ee\u5185\u5bb9: ${questionData.question}`, 'blue'); logger(`🏷️ \u9898\u76ee\u7c7b\u578b: ${questionData.type}`, 'blue'); logger(`📝 \u9009\u9879\u6570\u91cf: ${questionData.options.length}`, 'blue'); if (questionData.options.length > 0) { logger(`📋 \u9009\u9879\u5185\u5bb9: ${questionData.options.join(' | ')}`, 'blue'); } } catch (error) { logger(`❌ \u9898\u76ee\u6570\u636e\u63d0\u53d6\u5931\u8d25: ${error.message}`, 'red'); } return questionData; } // \u56db\u7ea7\u4f18\u5148\u7ea7\u7b54\u9898\u673a\u5236 - \u6839\u636e\u7528\u6237\u8bbe\u7f6e\u51b3\u5b9a\u4f7f\u7528\u54ea\u4e9b\u65b9\u5f0f function zhsGetAnswerWithPriority(questionData) { return new Promise((resolve, reject) => { // \u4e25\u683c\u68c0\u67e5API Key - \u8fd9\u662f\u7b2c\u4e8c\u4e2a\u5173\u952e\u9a8c\u8bc1\u70b9 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u6709\u6548\u7684key,\u4e14\u5f00\u542f\u4e86\u9700\u8981key\u7684\u529f\u80fd,\u5219\u62d2\u7edd\u7b54\u9898 if (!userKey || userKey.trim() === '' || userKey === '1') { if (useAI || useTiku) { reject('AI\u7b54\u9898\u529f\u80fd\u672a\u5f00\u542f'); return; } } // \u68c0\u67e5\u662f\u5426\u624b\u52a8\u505c\u6b62\u7b54\u9898 if (localStorage.getItem('GPTJsSetting.work') === 'false') { reject('\u7528\u6237\u624b\u52a8\u505c\u6b62\u7b54\u9898'); return; } // \u83b7\u53d6\u7528\u6237\u8bbe\u7f6e // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664 - \u6839\u636e\u7528\u6237\u8981\u6c42\u5b8c\u5168\u5220\u9664\u968f\u673a\u9009\u62e9\u529f\u80fd // \u5907\u7528\u9898\u5e93\u529f\u80fd\u5df2\u5220\u9664 - \u6839\u636e\u7528\u6237\u8981\u6c42\u5b8c\u5168\u5220\u9664\u5907\u7528\u9898\u5e93\u529f\u80fd // \u7b2c\u4e00\u4f18\u5148\u7ea7:\u4e3b\u9898\u5e93API if (useTiku && userKey) { // \u4e3a\u9898\u5e93API\u63d0\u4f9b\u7eaf\u51c0\u7684\u9898\u76ee\u5185\u5bb9 const tikuQuestionData = { question: questionData.question, type: questionData.type, options: questionData.options }; getZhihuishuAnswer(tikuQuestionData).then(answer => { // \u68c0\u67e5\u662f\u5426\u624b\u52a8\u505c\u6b62\u7b54\u9898 if (localStorage.getItem('GPTJsSetting.work') === 'false') { reject('\u7528\u6237\u624b\u52a8\u505c\u6b62\u7b54\u9898'); return; } if (answer && answer !== '\u6682\u65e0\u7b54\u6848') { logger(`📚 \u9898\u5e93API\u6210\u529f\u8fd4\u56de\u7b54\u6848: ${answer}`, 'green'); logger(`📚 \u7b54\u6848\u6765\u6e90: \u4e3b\u9898\u5e93API (tk.mixuelo.cc)`, 'blue'); resolve(answer); return; } logger(`📚 \u4e3b\u9898\u5e93API\u672a\u8fd4\u56de\u6709\u6548\u7b54\u6848,\u5c1d\u8bd5AI\u7b54\u9898...`, 'orange'); // \u4e3b\u9898\u5e93\u5931\u8d25,\u76f4\u63a5\u5c1d\u8bd5AI\u7b54\u9898 tryAI(); }).catch((error) => { logger(`📚 \u4e3b\u9898\u5e93API\u8c03\u7528\u5931\u8d25: ${error}`, 'red'); tryAI(); }); } else { tryAI(); } // \u7b2c\u4e09\u4f18\u5148\u7ea7:AI\u7b54\u9898 function tryAI() { // \u79fb\u9664\u7b54\u9898\u505c\u6b62\u68c0\u67e5 - \u9ed8\u8ba4\u603b\u662f\u7b54\u9898 // if (localStorage.getItem('GPTJsSetting.work') !== 'true') { // reject('\u7b54\u9898\u5df2\u505c\u6b62'); // return; // } if (useAI && userKey) { // \u4e3aAI\u6784\u5efa\u5b8c\u6574\u7684\u9898\u76ee\u4fe1\u606f(\u9898\u578b+\u9898\u76ee+\u9009\u9879)- \u4fee\u590dAI\u6ca1\u6709\u6536\u5230\u9009\u9879\u4fe1\u606f\u7684\u95ee\u9898 let aiQuestionText = ''; if (questionData.type) { aiQuestionText += questionData.type + ': '; } aiQuestionText += questionData.question; // \u6dfb\u52a0\u9009\u9879\u4fe1\u606f if (questionData.options && questionData.options.length > 0) { aiQuestionText += '\n\u9009\u9879:\n'; questionData.options.forEach((option, index) => { const optionLabel = String.fromCharCode(65 + index); // A, B, C, D // \u4fee\u590d\u9009\u9879\u4fe1\u606f\u4f20\u9012\u95ee\u9898 - \u786e\u4fdd\u63d0\u53d6\u5b9e\u9645\u7684\u9009\u9879\u6587\u672c const optionText = option.content ? option.content.replace(/<[^>]*>/g, '').trim() : option.text ? option.text.trim() : (typeof option === 'string' ? option : String(option)); aiQuestionText += `${optionLabel}. ${optionText}\n`; }); } logger(`🤖 \u53d1\u9001\u7ed9AI\u7684\u5b8c\u6574\u9898\u76ee\u4fe1\u606f: ${aiQuestionText.substring(0, 200)}...`, 'blue'); zhsGetAIAnswer(aiQuestionText, questionData.type) .then(answer => { // \u79fb\u9664\u7b54\u9898\u505c\u6b62\u68c0\u67e5 - \u9ed8\u8ba4\u603b\u662f\u7b54\u9898 // if (localStorage.getItem('GPTJsSetting.work') !== 'true') { // reject('\u7b54\u9898\u5df2\u505c\u6b62'); // return; // } if (answer && answer !== '\u6682\u65e0\u7b54\u6848' && answer.trim() !== '') { logger(`🤖 AI\u6210\u529f\u8fd4\u56de\u7b54\u6848: ${answer}`, 'green'); logger(`🤖 \u7b54\u6848\u6765\u6e90: AI\u7b54\u9898\u7cfb\u7edf`, 'blue'); resolve(answer); return; } logger(`🤖 AI\u672a\u8fd4\u56de\u6709\u6548\u7b54\u6848,\u8df3\u8fc7\u5f53\u524d\u9898\u76ee`, 'orange'); // AI\u5931\u8d25,\u4e0d\u518d\u4f7f\u7528\u968f\u673a\u7b54\u9898,\u76f4\u63a5\u8df3\u8fc7 reject('AI\u7b54\u9898\u5931\u8d25,\u65e0\u6cd5\u83b7\u53d6\u7b54\u6848'); }) .catch((error) => { logger(`🤖 AI\u7b54\u9898\u8c03\u7528\u5931\u8d25: ${error}`, 'red'); reject('AI\u7b54\u9898\u5931\u8d25: ' + error); }); } else { reject('AI\u7b54\u9898\u529f\u80fd\u672a\u5f00\u542f'); } } // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664 - \u6839\u636e\u7528\u6237\u8981\u6c42\u5b8c\u5168\u5220\u9664\u968f\u673a\u9009\u62e9\u529f\u80fd }); } // \u9009\u62e9\u7b54\u6848 - \u57fa\u4e8e\u5b9e\u9645DOM\u7ed3\u6784\u548cxxt.js\u67b6\u6784 function zhsSelectAnswer(questionElement, answer) { try { logger(`🎯 \u5f00\u59cb\u9009\u62e9\u7b54\u6848: ${answer}`, 'green'); // \u67e5\u627eradiogroup\u4e2d\u7684radio\u5143\u7d20 - \u4f7f\u7528role\u5c5e\u6027 const radioGroup = questionElement.find('[role="radiogroup"]'); if (radioGroup.length === 0) { logger(`❌ \u672a\u627e\u5230role="radiogroup"\u5143\u7d20`, 'red'); return false; } const radioElements = radioGroup.find('[role="radio"]'); let bestMatch = { element: null, score: 0, reason: '' }; radioElements.each(function () { const $radio = $(this); const optionText = $radio.attr('aria-label') || $radio.text().trim(); if (!optionText) return; // \u6e05\u7406\u9009\u9879\u6587\u672c const cleanOption = optionText.replace(/^[A-Z]\.\s*/, '').trim(); // \u591a\u79cd\u5339\u914d\u65b9\u5f0f,\u53c2\u8003xxt.js\u7684\u5339\u914d\u903b\u8f91 let matchScore = 0; let matchReason = ''; // 1. \u7cbe\u786e\u5339\u914d if (cleanOption === answer) { matchScore = 100; matchReason = '\u7cbe\u786e\u5339\u914d'; } // 2. \u5305\u542b\u5339\u914d else if (cleanOption.includes(answer) || answer.includes(cleanOption)) { matchScore = 80; matchReason = '\u5305\u542b\u5339\u914d'; } // 3. \u5173\u952e\u8bcd\u5339\u914d else { const answerWords = answer.split(/\s+/); const optionWords = cleanOption.split(/\s+/); let commonWords = 0; answerWords.forEach(word => { if (word.length > 1 && optionWords.some(optWord => optWord.includes(word) || word.includes(optWord))) { commonWords++; } }); if (commonWords > 0) { matchScore = (commonWords / Math.max(answerWords.length, optionWords.length)) * 60; matchReason = `\u5173\u952e\u8bcd\u5339\u914d(${commonWords}\u4e2a)`; } } if (matchScore > bestMatch.score) { bestMatch = { element: $radio, score: matchScore, reason: matchReason }; } logger(`\u9009\u9879\u5339\u914d: "${cleanOption}" -> \u5f97\u5206: ${matchScore.toFixed(1)}, \u539f\u56e0: ${matchReason}`, 'blue'); }); // \u9009\u62e9\u6700\u4f73\u5339\u914d\u7684\u9009\u9879 if (bestMatch.element && bestMatch.score > 30) { logger(`✅ \u9009\u62e9\u6700\u4f73\u5339\u914d\u9009\u9879,\u5f97\u5206: ${bestMatch.score.toFixed(1)}, \u539f\u56e0: ${bestMatch.reason}`, 'green'); // \u70b9\u51fb\u9009\u9879 - \u53c2\u8003xxt.js\u7684\u70b9\u51fb\u65b9\u5f0f bestMatch.element.click(); // \u989d\u5916\u5c1d\u8bd5\u70b9\u51fb\u5185\u90e8\u7684radio\u5143\u7d20 setTimeout(() => { const innerRadio = bestMatch.element.find('radio').first(); if (innerRadio.length > 0) { innerRadio.click(); } }, 100); // \u6dfb\u52a0\u6210\u529f\u72b6\u6001\u6307\u793a\u5668 - \u4fee\u590dquestionData\u672a\u5b9a\u4e49\u9519\u8bef const questionNumber = getCurrentQuestionNumber(); const actualQuestionText = getQuestionText(questionElement) || '\u9898\u76ee\u5185\u5bb9\u83b7\u53d6\u5931\u8d25'; addQuestionStatusIndicator(questionNumber, 'success', { question: actualQuestionText, answer: answer, selected: bestMatch.optionText || '\u5df2\u9009\u62e9', type: '\u5355\u9009\u9898' }); return true; } else { logger(`❌ \u672a\u627e\u5230\u5339\u914d\u7684\u9009\u9879,\u6700\u9ad8\u5f97\u5206: ${bestMatch.score.toFixed(1)}`, 'red'); // \u6dfb\u52a0\u5931\u8d25\u72b6\u6001\u6307\u793a\u5668 - \u4fee\u590dquestionData\u672a\u5b9a\u4e49\u9519\u8bef const questionNumber = getCurrentQuestionNumber(); const actualQuestionText = getQuestionText(questionElement) || '\u9898\u76ee\u5185\u5bb9\u83b7\u53d6\u5931\u8d25'; addQuestionStatusIndicator(questionNumber, 'failed', { question: actualQuestionText, answer: answer, error: '\u672a\u627e\u5230\u9009\u9879\u6216,\u5df2\u7ecf\u7b54\u9898', type: '\u5355\u9009\u9898' }); return false; } } catch (error) { logger(`❌ \u9009\u62e9\u7b54\u6848\u5931\u8d25: ${error.message}`, 'red'); return false; } } // \u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898 - \u57fa\u4e8e\u5b9e\u9645DOM\u7ed3\u6784\u548cxxt.js\u6a21\u5f0f function zhsNavigateToNext() { try { // \u9996\u5148\u68c0\u67e5\u7b54\u9898\u72b6\u6001 - \u53ea\u6709\u5728\u7b54\u9898\u5f00\u542f\u65f6\u624d\u81ea\u52a8\u5bfc\u822a const isAutoAnswerEnabled = localStorage.getItem('GPTJsSetting.work') === 'true'; if (!isAutoAnswerEnabled) { logger(`🛑 \u81ea\u52a8\u7b54\u9898\u5df2\u5173\u95ed,\u505c\u6b62\u81ea\u52a8\u5bfc\u822a`, 'orange'); return false; } // \u9a8c\u8bc1API Key - \u5fc5\u987b\u914d\u7f6e\u6b63\u786ekey\u624d\u80fd\u81ea\u52a8\u5bfc\u822a const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; if (!userKey || userKey.trim() === '' || userKey === '1') { logger(`🛑 \u672a\u914d\u7f6e\u6709\u6548Key,\u505c\u6b62\u81ea\u52a8\u5bfc\u822a`, 'orange'); return false; } // \u67e5\u627e"\u4e0b\u4e00\u9898"\u6309\u94ae - \u4f7f\u7528\u6587\u672c\u5339\u914d\u548c\u5b9e\u9645HTML\u5143\u7d20 let nextButton = $('*:contains("\u4e0b\u4e00\u9898")').filter(function () { return $(this).text().trim() === '\u4e0b\u4e00\u9898'; }); // \u5982\u679c\u6ca1\u627e\u5230,\u5c1d\u8bd5\u5176\u4ed6\u9009\u62e9\u5668 if (nextButton.length === 0) { nextButton = $('button:contains("\u4e0b\u4e00\u9898"), div:contains("\u4e0b\u4e00\u9898"), span:contains("\u4e0b\u4e00\u9898")').filter(function () { return $(this).text().trim() === '\u4e0b\u4e00\u9898'; }); } if (nextButton.length > 0 && nextButton.is(':visible')) { logger(`🔄 \u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898`, 'blue'); nextButton.click(); return true; } else { logger(`⚠️ \u672a\u627e\u5230"\u4e0b\u4e00\u9898"\u6309\u94ae\u6216\u6309\u94ae\u4e0d\u53ef\u89c1`, 'orange'); return false; } } catch (error) { logger(`❌ \u5bfc\u822a\u5230\u4e0b\u4e00\u9898\u5931\u8d25: ${error.message}`, 'red'); return false; } } // \u667a\u6167\u6811\u67e5\u627e\u7b54\u6848\u4e3b\u51fd\u6570 - \u91cd\u6784\u4e3a\u57fa\u4e8exxt.js\u7684\u7b80\u5355\u67b6\u6784 function zhsFindAnswer(tip) { if (setting.queue.length) { return; } // \u79fb\u9664\u81ea\u52a8\u7b54\u9898\u529f\u80fd\u68c0\u67e5 - \u9ed8\u8ba4\u603b\u662f\u7b54\u9898 // if (!setting.work) { // // \u9759\u9ed8\u8fd4\u56de,\u4e0d\u8f93\u51fa\u65e5\u5fd7\u907f\u514d\u5e72\u6270 // return; // } // \u667a\u6167\u6811\u4f7f\u7528API\u62e6\u622a\u65b9\u5f0f,\u4e0d\u9700\u8981DOM\u68c0\u6d4b // \u8fd9\u4e2a\u51fd\u6570\u4e3b\u8981\u7528\u4e8e\u5904\u7406\u961f\u5217\u4e2d\u7684\u70b9\u51fb\u64cd\u4f5c\u548c\u72b6\u6001\u68c0\u67e5 // \u68c0\u67e5\u662f\u5426\u5728\u667a\u6167\u6811\u7b54\u9898\u9875\u9762 if (tip && !location.href.includes('zhihuishu.com')) { return; } // \u667a\u6167\u6811\u7684\u9898\u76ee\u901a\u8fc7API\u62e6\u622a\u5904\u7406,\u8fd9\u91cc\u53ea\u5904\u7406\u57fa\u672c\u72b6\u6001 // \u4e0d\u518d\u8f93\u51fa"\u7b54\u9898\u5df2\u5b8c\u6210",\u907f\u514d\u8bef\u5bfc\u7528\u6237 // \u5982\u679c\u6709\u5f85\u5904\u7406\u7684\u70b9\u51fb\u961f\u5217,\u4f18\u5148\u5904\u7406 if (setting.queue.length > 0) { return; } // \u68c0\u67e5\u662f\u5426\u6709\u4e0b\u4e00\u9898\u6309\u94ae\u9700\u8981\u70b9\u51fb const nextBtn = document.querySelector('.Topicswitchingbtn'); if (nextBtn && nextBtn.textContent.includes('\u4e0b\u4e00\u9898') && setting.queue.length === 0) { // \u8ba9\u81ea\u52a8\u8df3\u8f6c\u903b\u8f91\u5904\u7406,\u8fd9\u91cc\u4e0d\u91cd\u590d\u5904\u7406 return; } } // \u667a\u6167\u6811\u586b\u5145\u7b54\u6848\u51fd\u6570 function zhsFillAnswer($TiMu, obj, type) { const $div = $TiMu.find('.nodeLab'); const str = String(obj.answer).toCDB() || new Date().toString(); const answer = str.split(/#|\x01|\|/); const state = setting.lose; logger(`\u5f00\u59cb\u586b\u5145\u7b54\u6848,\u9898\u76ee\u7c7b\u578b: ${type},\u7b54\u6848: ${obj.answer}`, 'blue'); obj.code > 0 && $div.each(function () { const $input = $('input', this)[0]; if (!$input) return; const tip = filterStyle('.node_detail', this).toCDB() || new Date().toString(); if (tip.match(/^(\u6b63\u786e|\u662f|\u5bf9|√|T|ri)$/)) { answer.join().match(/(^|,)(\u6b63\u786e|\u662f|\u5bf9|√|T|ri)(,|$)/) && setting.queue.push($input); } else if (tip.match(/^(\u9519\u8bef|\u5426|\u9519|×|F|wr)$/)) { answer.join().match(/(^|,)(\u9519\u8bef|\u5426|\u9519|×|F|wr)(,|$)/) && setting.queue.push($input); } else if (type == 2) { // \u591a\u9009\u9898 Boolean($.inArray(tip, answer) + 1 || str.indexOf(tip) + 1) == $input.checked || setting.queue.push($input); } else { // \u5355\u9009\u9898 $.inArray(tip, answer) + 1 && setting.queue.push($input); } }); if (setting.queue.length) { logger(`\u5df2\u6dfb\u52a0 ${setting.queue.length} \u4e2a\u9009\u9879\u5230\u70b9\u51fb\u961f\u5217`, 'green'); return true; } else if (/^(1|2|14)$/.test(type)) { const $input = $div.find('input'); if (!$input.is(':checked')) { setting.lose++; logger('❌ \u672a\u627e\u5230\u5339\u914d\u7684\u9009\u9879', 'red'); return false; } } else if (/^[3-5]$/.test(type)) { // \u586b\u7a7a\u9898/\u7b80\u7b54\u9898 const answers = String(obj.answer).split(/#|\x01|\|/); let filled = 0; $TiMu.find('textarea').each(function (index) { const answerText = (obj.code > 0 && answers[index]) || ''; if (answerText) { this.value = answerText.trim(); this.dispatchEvent(new Event('input')); this.dispatchEvent(new Event('blur')); filled++; } }); if (obj.code > 0 && filled > 0) { logger(`\u5df2\u586b\u5145 ${filled} \u4e2a\u6587\u672c\u6846`, 'green'); return true; } else if (!setting.none) { setting.lose++; logger('\u586b\u7a7a\u9898\u7b54\u6848\u586b\u5145\u5931\u8d25', 'red'); return false; } } else { if (!setting.none) { setting.lose++; logger('\u672a\u77e5\u9898\u578b,\u65e0\u6cd5\u5904\u7406', 'red'); return false; } } return true; } // \u667a\u6167\u6811\u8003\u8bd5\u9875\u9762\u521d\u59cb\u5316(\u5907\u7528)- \u5df2\u7981\u7528,\u4f7f\u7528\u65b0\u7684zhsProcessQuestions\u7cfb\u7edf function initZhihuishuExam() { logger('\u5907\u7528\u521d\u59cb\u5316\u7cfb\u7edf\u5df2\u7981\u7528,\u4f7f\u7528\u4e3b\u8981\u7684zhsProcessQuestions\u7cfb\u7edf', 'blue'); // \u76f4\u63a5\u8c03\u7528\u4e3b\u8981\u7684\u5904\u7406\u7cfb\u7edf,\u907f\u514d\u51b2\u7a81 zhsProcessQuestions(); } // \u5f00\u59cb\u667a\u6167\u6811\u81ea\u52a8\u7b54\u9898 - \u5df2\u7981\u7528,\u4f7f\u7528\u65b0\u7684zhsProcessQuestions\u7cfb\u7edf function startZhihuishuAutoAnswer() { logger('\u65e7\u7684\u81ea\u52a8\u7b54\u9898\u7cfb\u7edf\u5df2\u7981\u7528,\u4f7f\u7528\u4e3b\u8981\u7684zhsProcessQuestions\u7cfb\u7edf', 'blue'); // \u76f4\u63a5\u8c03\u7528\u4e3b\u8981\u7684\u5904\u7406\u7cfb\u7edf,\u907f\u514d\u51b2\u7a81 zhsProcessQuestions(); } // \u67e5\u627e\u667a\u6167\u6811\u9898\u76ee function findZhihuishuQuestions() { // \u667a\u6167\u6811\u8003\u8bd5\u9875\u9762\u7684\u9898\u76ee\u901a\u5e38\u5728\u7279\u5b9a\u7684\u5bb9\u5668\u4e2d const questionContainers = []; // \u65b9\u6cd51:\u67e5\u627e\u5305\u542b\u9898\u76ee\u548c\u9009\u9879\u7684\u5b8c\u6574\u5bb9\u5668 const questionBlocks = document.querySelectorAll('.question-block, .exam-question, [class*="question-container"]'); if (questionBlocks.length > 0) { logger(`\u627e\u5230 ${questionBlocks.length} \u4e2a\u9898\u76ee\u5757\u5bb9\u5668`, 'blue'); return Array.from(questionBlocks); } // \u65b9\u6cd52:\u901a\u8fc7\u9009\u9879\u5217\u8868\u53cd\u63a8\u9898\u76ee\u5bb9\u5668 const optionLists = document.querySelectorAll('.optionUl'); if (optionLists.length > 0) { logger(`\u901a\u8fc7\u9009\u9879\u5217\u8868\u627e\u5230 ${optionLists.length} \u9053\u9898\u76ee`, 'blue'); optionLists.forEach((optionList) => { // \u67e5\u627e\u5305\u542b\u9898\u76ee\u548c\u9009\u9879\u7684\u7236\u5bb9\u5668 let container = optionList.parentElement; // \u5411\u4e0a\u67e5\u627e,\u76f4\u5230\u627e\u5230\u5305\u542b\u9898\u76ee\u6587\u672c\u7684\u5bb9\u5668 while (container && container !== document.body) { const questionText = container.querySelector('p, .question-text, .stem'); if (questionText && questionText.textContent.trim().length > 10) { questionContainers.push(container); break; } container = container.parentElement; } // \u5982\u679c\u6ca1\u627e\u5230\u5408\u9002\u7684\u5bb9\u5668,\u4f7f\u7528\u9009\u9879\u5217\u8868\u7684\u7236\u5143\u7d20 if (!questionContainers.includes(container) && optionList.parentElement) { questionContainers.push(optionList.parentElement); } }); return questionContainers; } // \u65b9\u6cd53:\u67e5\u627e\u6240\u6709\u53ef\u80fd\u7684\u9898\u76ee\u5bb9\u5668 const selectors = [ '.subject_stem', // \u9898\u76ee\u4e3b\u4f53 '.question-item', // \u9898\u76ee\u9879 '[class*="question"]', // \u5305\u542bquestion\u7684\u7c7b\u540d '.exam-item', // \u8003\u8bd5\u9879\u76ee '.test-item' // \u6d4b\u8bd5\u9879\u76ee ]; for (const selector of selectors) { const elements = document.querySelectorAll(selector); if (elements.length > 0 && elements.length < 50) { // \u5408\u7406\u7684\u9898\u76ee\u6570\u91cf logger(`\u4f7f\u7528\u9009\u62e9\u5668 "${selector}" \u627e\u5230 ${elements.length} \u4e2a\u9898\u76ee`, 'blue'); return Array.from(elements).filter(el => el.textContent.trim().length > 5); } } // \u65b9\u6cd54:\u5982\u679c\u90fd\u6ca1\u627e\u5230,\u5c1d\u8bd5\u5206\u6790\u9875\u9762\u7ed3\u6784 logger('\u5c1d\u8bd5\u5206\u6790\u9875\u9762\u7ed3\u6784\u67e5\u627e\u9898\u76ee', 'orange'); const allElements = document.querySelectorAll('div, section, article'); const potentialQuestions = []; allElements.forEach(el => { // \u67e5\u627e\u5305\u542b\u9009\u9879\u5217\u8868\u7684\u5143\u7d20 const hasOptions = el.querySelector('.optionUl, .el-radio-group, input[type="radio"]'); // \u67e5\u627e\u5305\u542b\u9898\u76ee\u6587\u672c\u7684\u5143\u7d20 const hasQuestionText = el.querySelector('p') && el.textContent.trim().length > 20; if (hasOptions && hasQuestionText && !potentialQuestions.includes(el)) { potentialQuestions.push(el); } }); if (potentialQuestions.length > 0) { logger(`\u901a\u8fc7\u9875\u9762\u7ed3\u6784\u5206\u6790\u627e\u5230 ${potentialQuestions.length} \u4e2a\u6f5c\u5728\u9898\u76ee`, 'blue'); return potentialQuestions; } logger('\u672a\u627e\u5230\u4efb\u4f55\u9898\u76ee\u5bb9\u5668', 'red'); return []; } // \u5904\u7406\u667a\u6167\u6811\u9898\u76ee - \u5df2\u7981\u7528,\u4f7f\u7528\u65b0\u7684zhsProcessQuestions\u7cfb\u7edf function processZhihuishuQuestion(index, questionContainers) { logger('\u65e7\u7684\u9898\u76ee\u5904\u7406\u7cfb\u7edf\u5df2\u7981\u7528,\u4f7f\u7528\u4e3b\u8981\u7684zhsProcessQuestions\u7cfb\u7edf', 'blue'); // \u76f4\u63a5\u8c03\u7528\u4e3b\u8981\u7684\u5904\u7406\u7cfb\u7edf,\u907f\u514d\u51b2\u7a81 return; } // \u70b9\u51fb\u667a\u6167\u6811\u4e0b\u4e00\u9898\u6309\u94ae function clickNextQuestionButton() { try { // \u9996\u5148\u68c0\u67e5\u7b54\u9898\u72b6\u6001 - \u53ea\u6709\u5728\u7b54\u9898\u5f00\u542f\u65f6\u624d\u70b9\u51fb\u4e0b\u4e00\u9898 const isAutoAnswerEnabled = localStorage.getItem('GPTJsSetting.work') === 'true'; if (!isAutoAnswerEnabled) { logger(`🛑 \u81ea\u52a8\u7b54\u9898\u5df2\u5173\u95ed,\u505c\u6b62\u70b9\u51fb\u4e0b\u4e00\u9898\u6309\u94ae`, 'orange'); return false; } // \u9a8c\u8bc1API Key - \u5fc5\u987b\u914d\u7f6e\u6b63\u786ekey\u624d\u80fd\u70b9\u51fb\u4e0b\u4e00\u9898 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; if (!userKey || userKey.trim() === '' || userKey === '1') { logger(`🛑 \u672a\u914d\u7f6e\u6709\u6548Key,\u505c\u6b62\u70b9\u51fb\u4e0b\u4e00\u9898\u6309\u94ae`, 'orange'); return false; } // \u667a\u6167\u6811\u4e0b\u4e00\u9898\u6309\u94ae\u7684\u591a\u79cd\u53ef\u80fd\u9009\u62e9\u5668 const nextButtonSelectors = [ '.Topicswitchingbtn:contains(\u4e0b\u4e00\u9898)', // \u539f\u59cb\u667a\u6167\u6811\u7f51\u8bfe\u514d\u8d39\u52a9\u624b\u4f7f\u7528\u7684\u9009\u62e9\u5668 '.next-btn', // \u901a\u7528\u4e0b\u4e00\u9898\u6309\u94ae '.btn-next', // \u53e6\u4e00\u79cd\u4e0b\u4e00\u9898\u6309\u94ae '[class*="next"]', // \u5305\u542bnext\u7684\u7c7b\u540d 'button:contains(\u4e0b\u4e00\u9898)', // \u5305\u542b"\u4e0b\u4e00\u9898"\u6587\u672c\u7684\u6309\u94ae 'a:contains(\u4e0b\u4e00\u9898)', // \u5305\u542b"\u4e0b\u4e00\u9898"\u6587\u672c\u7684\u94fe\u63a5 '.nextDiv a', // \u4e0b\u4e00\u9898\u533a\u57df\u7684\u94fe\u63a5 '.jb_btn:contains(\u4e0b\u4e00\u9898)' // \u7279\u5b9a\u6837\u5f0f\u7684\u4e0b\u4e00\u9898\u6309\u94ae ]; let nextButton = null; // \u5c1d\u8bd5\u627e\u5230\u4e0b\u4e00\u9898\u6309\u94ae for (const selector of nextButtonSelectors) { if (selector.includes(':contains(')) { // \u5bf9\u4e8e\u5305\u542b:contains\u7684\u9009\u62e9\u5668,\u9700\u8981\u7279\u6b8a\u5904\u7406 const baseSelector = selector.split(':contains(')[0]; const containsText = selector.match(/:contains\((.+?)\)/)[1]; const elements = document.querySelectorAll(baseSelector); for (const element of elements) { if (element.textContent.includes(containsText)) { nextButton = element; break; } } } else { nextButton = document.querySelector(selector); } if (nextButton) { logger(`\u627e\u5230\u4e0b\u4e00\u9898\u6309\u94ae,\u4f7f\u7528\u9009\u62e9\u5668: ${selector}`, 'blue'); break; } } if (nextButton) { // \u68c0\u67e5\u6309\u94ae\u662f\u5426\u53ef\u70b9\u51fb if (nextButton.disabled || nextButton.style.display === 'none' || nextButton.style.visibility === 'hidden') { logger('\u4e0b\u4e00\u9898\u6309\u94ae\u4e0d\u53ef\u70b9\u51fb,\u8df3\u8fc7', 'orange'); return false; } // \u70b9\u51fb\u4e0b\u4e00\u9898\u6309\u94ae nextButton.click(); logger('\u6210\u529f\u70b9\u51fb\u4e0b\u4e00\u9898\u6309\u94ae', 'green'); return true; } else { logger('\u672a\u627e\u5230\u4e0b\u4e00\u9898\u6309\u94ae,\u53ef\u80fd\u5df2\u662f\u6700\u540e\u4e00\u9898', 'orange'); // \u5c1d\u8bd5\u67e5\u627e\u63d0\u4ea4\u6309\u94ae const submitSelectors = [ '.submit-btn', '.btn-submit', '[class*="submit"]', 'button:contains(\u63d0\u4ea4)', 'a:contains(\u63d0\u4ea4)', '.submitDiv button', '.jb_btn:contains(\u63d0\u4ea4)' ]; for (const selector of submitSelectors) { let submitButton = null; if (selector.includes(':contains(')) { const baseSelector = selector.split(':contains(')[0]; const containsText = selector.match(/:contains\((.+?)\)/)[1]; const elements = document.querySelectorAll(baseSelector); for (const element of elements) { if (element.textContent.includes(containsText)) { submitButton = element; break; } } } else { submitButton = document.querySelector(selector); } if (submitButton) { logger(`\u627e\u5230\u63d0\u4ea4\u6309\u94ae,\u51c6\u5907\u63d0\u4ea4: ${selector}`, 'blue'); setTimeout(() => { submitButton.click(); logger('\u5df2\u70b9\u51fb\u63d0\u4ea4\u6309\u94ae', 'green'); }, 2000); return true; } } return false; } } catch (error) { logger(`\u70b9\u51fb\u4e0b\u4e00\u9898\u6309\u94ae\u65f6\u51fa\u9519: ${error}`, 'red'); return false; } } // \u89e3\u6790\u667a\u6167\u6811\u9898\u76ee function parseZhihuishuQuestion(container) { try { // \u67e5\u627e\u9898\u76ee\u6587\u672c let questionText = ''; // \u9996\u5148\u5c1d\u8bd5\u67e5\u627e\u9898\u76ee\u6587\u672c,\u6392\u9664\u9009\u9879\u533a\u57df const questionSelectors = [ 'p:not(.optionUl p):not(.el-radio p)', // p\u6807\u7b7e\u4f46\u4e0d\u5728\u9009\u9879\u533a\u57df\u5185 '.question-text', '.subject_stem', '.question-content', '.stem', '.title' ]; for (const selector of questionSelectors) { const questionElements = container.querySelectorAll(selector); for (const questionElement of questionElements) { const text = questionElement.textContent.trim(); // \u786e\u4fdd\u4e0d\u662f\u9009\u9879\u6587\u672c,\u4e14\u6709\u8db3\u591f\u957f\u5ea6 if (text && text.length > 10 && !text.match(/^[A-D]\./) && !questionElement.closest('.optionUl') && !questionElement.closest('.el-radio')) { questionText = text; break; } } if (questionText) break; } // \u5982\u679c\u8fd8\u6ca1\u627e\u5230\u9898\u76ee\u6587\u672c,\u5c1d\u8bd5\u4ece\u5bb9\u5668\u7684\u76f4\u63a5\u6587\u672c\u5185\u5bb9\u83b7\u53d6 if (!questionText) { const allText = container.textContent.trim(); const lines = allText.split('\n').map(line => line.trim()).filter(line => line); // \u67e5\u627e\u6700\u53ef\u80fd\u662f\u9898\u76ee\u7684\u884c for (const line of lines) { // \u8df3\u8fc7\u660e\u663e\u7684\u9009\u9879\u884c、\u6807\u9898\u884c、\u5206\u6570\u884c\u7b49 if (!line.match(/^[A-D]\./) && !line.match(/^\d+\.\s*【/) && !line.match(/\u603b\u5206|\u9898\u76ee\u6570|\u5206\u6570/) && !line.match(/^[\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341]+、/) && line.length > 15 && line.length < 200) { questionText = line; break; } } } // \u67e5\u627e\u9009\u9879 - \u6539\u8fdb\u7684\u9009\u9879\u67e5\u627e\u903b\u8f91 const options = []; // \u65b9\u6cd51:\u67e5\u627e\u6807\u51c6\u7684\u667a\u6167\u6811\u9009\u9879\u7ed3\u6784 const optionContainers = container.querySelectorAll('.optionUl'); if (optionContainers.length > 0) { logger(`\u627e\u5230 ${optionContainers.length} \u4e2a\u9009\u9879\u5bb9\u5668`, 'blue'); optionContainers.forEach(optionContainer => { const optionElements = optionContainer.querySelectorAll('.el-radio, label[role="radio"]'); optionElements.forEach((element, index) => { const optionContent = element.querySelector('.optionContent'); const radioInput = element.querySelector('input[type="radio"]'); let optionText = ''; if (optionContent) { optionText = optionContent.textContent.trim(); } else { // \u5c1d\u8bd5\u5176\u4ed6\u65b9\u5f0f\u83b7\u53d6\u9009\u9879\u6587\u672c const spans = element.querySelectorAll('span'); for (const span of spans) { const text = span.textContent.trim(); if (text && !text.match(/^[A-D]\.?$/) && text.length > 1) { optionText = text; break; } } // \u5982\u679c\u8fd8\u662f\u6ca1\u627e\u5230,\u4f7f\u7528\u6574\u4e2a\u5143\u7d20\u7684\u6587\u672c if (!optionText) { optionText = element.textContent.trim(); } } // \u6e05\u7406\u9009\u9879\u6587\u672c,\u79fb\u9664\u9009\u9879\u6807\u7b7e optionText = optionText.replace(/^[A-D]\.?\s*/, '').trim(); // \u8fdb\u4e00\u6b65\u6e05\u7406,\u79fb\u9664\u591a\u4f59\u7684\u7a7a\u767d\u548c\u7279\u6b8a\u5b57\u7b26 optionText = optionText.replace(/\s+/g, ' ').trim(); if (optionText && optionText.length > 0 && optionText.length < 500) { options.push({ text: optionText, value: radioInput ? radioInput.value : `option_${index}`, element: element, input: radioInput }); logger(`\u89e3\u6790\u5230\u9009\u9879 ${String.fromCharCode(65 + index)}: ${optionText.substring(0, 30)}...`, 'blue'); } }); }); } // \u65b9\u6cd52:\u5982\u679c\u6ca1\u627e\u5230\u9009\u9879,\u5c1d\u8bd5\u76f4\u63a5\u67e5\u627eradio\u8f93\u5165 if (options.length === 0) { const radioInputs = container.querySelectorAll('input[type="radio"]'); if (radioInputs.length > 0) { logger(`\u901a\u8fc7radio\u8f93\u5165\u627e\u5230 ${radioInputs.length} \u4e2a\u9009\u9879`, 'blue'); radioInputs.forEach((radioInput, index) => { const label = radioInput.closest('label') || radioInput.parentElement; let optionText = ''; if (label) { optionText = label.textContent.trim(); optionText = optionText.replace(/^[A-D]\.?\s*/, '').trim(); if (optionText && optionText.length > 0 && optionText.length < 500) { options.push({ text: optionText, value: radioInput.value || `option_${index}`, element: label, input: radioInput }); } } }); } } // \u5224\u65ad\u9898\u76ee\u7c7b\u578b let questionType = 0; // \u9ed8\u8ba4\u5355\u9009\u9898 if (questionText.includes('\u591a\u9009') || questionText.includes('\u591a\u9879\u9009\u62e9')) { questionType = 1; // \u591a\u9009\u9898 } else if (questionText.includes('\u5224\u65ad') || questionText.includes('\u5bf9\u9519') || options.some(opt => opt.text.includes('\u6b63\u786e') || opt.text.includes('\u9519\u8bef') || opt.text.includes('\u5bf9') || opt.text.includes('\u9519') || opt.text.includes('\u662f') || opt.text.includes('\u5426') )) { questionType = 3; // \u5224\u65ad\u9898 } else if (questionText.includes('\u586b\u7a7a') || questionText.includes('\u7a7a\u767d')) { questionType = 2; // \u586b\u7a7a\u9898 } const result = { question: questionText, type: questionType, options: options, container: container }; logger(`\u9898\u76ee\u89e3\u6790\u5b8c\u6210 - \u9898\u76ee: "${questionText.substring(0, 50)}...", \u9009\u9879\u6570: ${options.length}, \u7c7b\u578b: ${questionType}`, 'green'); return result; } catch (error) { logger(`\u89e3\u6790\u9898\u76ee\u65f6\u51fa\u9519: ${error}`, 'red'); return null; } } // \u83b7\u53d6\u667a\u6167\u6811\u7b54\u6848 function getZhihuishuAnswer(questionData) { return new Promise((resolve, reject) => { // \u83b7\u53d6\u7528\u6237token,\u4f7f\u7528\u4e0exxt.js\u76f8\u540c\u7684\u65b9\u5f0f var userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || setting.token || ''; if (!userKey) { logger('\u672a\u8bbe\u7f6eAPI Key,\u65e0\u6cd5\u8c03\u7528\u9898\u5e93API', 'orange'); resolve(null); return; } // \u6784\u5efa\u9898\u76ee\u6587\u672c,\u5305\u542b\u9009\u9879 - \u4fee\u590d\u9009\u9879\u6570\u636e\u683c\u5f0f\u95ee\u9898 let questionWithOptions = questionData.question; var optionsText = ''; if (questionData.options.length > 0) { optionsText = questionData.options.map(function (option, index) { var label = String.fromCharCode(65 + index); // A, B, C, D... // \u5904\u7406\u9009\u9879\u53ef\u80fd\u662f\u5b57\u7b26\u4e32\u6216\u5bf9\u8c61\u7684\u60c5\u51b5 var optionText = typeof option === 'string' ? option : (option.text || option); return label + '.' + optionText; }).join('\n'); } // \u9898\u578b\u6620\u5c04 var typeMapping = { 0: '\u5355\u9009\u9898', 1: '\u5355\u9009\u9898', 2: '\u591a\u9009\u9898', 3: '\u586b\u7a7a\u9898', 4: '\u95ee\u7b54\u9898', 14: '\u5224\u65ad\u9898' }; var mappedType = typeMapping[questionData.type] || '\u5355\u9009\u9898'; // \u6784\u5efa\u8bf7\u6c42\u6570\u636e var requestData = "key=" + encodeURIComponent(userKey) + "&question=" + encodeURIComponent(questionData.question) + "&type=" + encodeURIComponent(mappedType); if (optionsText) { requestData += "&options=" + encodeURIComponent(optionsText); } logger('📚 \u53d1\u9001\u9898\u5e93API\u8bf7\u6c42\u5230 tk.mixuelo.cc...', 'blue'); // \u4f7f\u7528\u4e0exxt.js\u5b8c\u5168\u76f8\u540c\u7684API\u5730\u5740 const API_BASE_URL = (() => { const baseUrl = "tk.mixuelo.cc/api.php"; const protocol = window.location.protocol; if (protocol === 'https:') { return "https://" + baseUrl; } else { return "http://" + baseUrl; } })(); GM_xmlhttpRequest({ method: "POST", url: API_BASE_URL + "?act=query", headers: { "Content-Type": "application/x-www-form-urlencoded", "Cookie": "PHPSESSID=th9rcnfi47nl9fhjsjrcbmvq01" // \u6dfb\u52a0Cookie\u5934\u90e8,API Key\u901a\u8fc7data\u53c2\u6570\u4f20\u9012 }, data: requestData, timeout: 30000, // \u4fee\u590d\u4e3b\u9898\u5e93\u67e5\u8be2\u95ee\u9898 - \u589e\u52a0\u8d85\u65f6\u65f6\u95f4\u523030\u79d2 onload: function (response) { try { logger(`📚 \u9898\u5e93API\u54cd\u5e94\u72b6\u6001: ${response.status}`, 'blue'); logger(`📚 \u9898\u5e93API\u54cd\u5e94\u5185\u5bb9: ${response.responseText.substring(0, 200)}...`, 'blue'); if (response.status === 200) { var result = JSON.parse(response.responseText); if (result.code === 1 && result.data && result.data.trim() !== '') { logger(`📚 \u9898\u5e93API\u6210\u529f\u8fd4\u56de\u7b54\u6848: ${result.data}`, 'green'); resolve(result.data); } else { logger(`📚 \u9898\u5e93API\u8fd4\u56de\u9519\u8bef: ${result.msg || result.message || '\u672a\u77e5\u9519\u8bef'}`, 'orange'); resolve(null); } } else { logger(`📚 \u9898\u5e93API\u8bf7\u6c42\u5931\u8d25,\u72b6\u6001\u7801: ${response.status}`, 'red'); resolve(null); } } catch (e) { logger(`📚 \u89e3\u6790\u9898\u5e93API\u54cd\u5e94\u5931\u8d25: ${e.message}`, 'red'); logger(`📚 \u539f\u59cb\u54cd\u5e94\u5185\u5bb9: ${response.responseText}`, 'red'); resolve(null); } }, onerror: function (error) { logger(`📚 \u9898\u5e93API\u8bf7\u6c42\u7f51\u7edc\u9519\u8bef: ${error}`, 'red'); resolve(null); }, ontimeout: function () { logger('📚 \u9898\u5e93API\u8bf7\u6c42\u8d85\u65f6(30\u79d2)', 'red'); resolve(null); } }); }); } // \u9009\u62e9\u667a\u6167\u6811\u9009\u9879 function selectZhihuishuOption(questionData, answer) { try { const answerText = answer.toLowerCase().trim(); let selectedCount = 0; // \u904d\u5386\u9009\u9879\u5bfb\u627e\u5339\u914d questionData.options.forEach((option, index) => { // \u4fee\u590d\u9009\u9879\u6587\u672c\u83b7\u53d6\u95ee\u9898 - \u652f\u6301\u591a\u79cd\u6570\u636e\u7ed3\u6784 const optionText = (option.content || option.text || option || '').toString().replace(/<[^>]*>/g, '').toLowerCase().trim(); let shouldSelect = false; // \u5224\u65ad\u9898\u7279\u6b8a\u5904\u7406 if (questionData.type === 3) { if ((answerText.includes('\u6b63\u786e') || answerText.includes('\u5bf9') || answerText.includes('\u662f') || answerText.includes('√') || answerText.includes('t')) && (optionText.includes('\u6b63\u786e') || optionText.includes('\u5bf9') || optionText.includes('\u662f') || optionText.includes('√'))) { shouldSelect = true; } else if ((answerText.includes('\u9519\u8bef') || answerText.includes('\u9519') || answerText.includes('\u5426') || answerText.includes('×') || answerText.includes('f')) && (optionText.includes('\u9519\u8bef') || optionText.includes('\u9519') || optionText.includes('\u5426') || optionText.includes('×'))) { shouldSelect = true; } } else { // \u5176\u4ed6\u9898\u578b:\u68c0\u67e5\u7b54\u6848\u662f\u5426\u5305\u542b\u9009\u9879\u5185\u5bb9 if (answerText.includes(optionText) || optionText.includes(answerText)) { shouldSelect = true; } // \u68c0\u67e5\u9009\u9879\u6807\u7b7e\u5339\u914d (A, B, C, D) const optionLabel = String.fromCharCode(65 + index); if (answerText.includes(optionLabel.toLowerCase()) || answerText.includes(optionLabel)) { shouldSelect = true; } } if (shouldSelect) { // \u68c0\u67e5\u9009\u9879\u662f\u5426\u5df2\u7ecf\u88ab\u9009\u4e2d - \u4fee\u590d\u91cd\u590d\u9009\u62e9\u5bfc\u81f4\u7684\u5339\u914d\u5931\u8d25\u95ee\u9898 const isAlreadySelected = option.input && option.input.checked; if (isAlreadySelected) { // \u4fee\u590d\u65e5\u5fd7\u663e\u793a\u9009\u9879\u6587\u672c\u95ee\u9898 const displayText = (option.content || option.text || option || '').toString().replace(/<[^>]*>/g, '').trim(); logger(`\u9009\u9879 ${String.fromCharCode(65 + index)} \u5df2\u88ab\u9009\u4e2d: ${displayText}`, 'blue'); selectedCount++; } else { clickZhihuishuOption(option); selectedCount++; // \u4fee\u590d\u65e5\u5fd7\u663e\u793a\u9009\u9879\u6587\u672c\u95ee\u9898 const displayText = (option.content || option.text || option || '').toString().replace(/<[^>]*>/g, '').trim(); logger(`\u9009\u62e9\u4e86\u9009\u9879 ${String.fromCharCode(65 + index)}: ${displayText}`, 'green'); } // \u5355\u9009\u9898\u53ea\u9009\u62e9\u4e00\u4e2a\u9009\u9879 if (questionData.type === 0) { return; } } }); if (selectedCount === 0) { // \u68c0\u67e5\u662f\u5426\u6240\u6709\u9009\u9879\u90fd\u5df2\u7ecf\u88ab\u9009\u4e2d const alreadySelectedCount = questionData.options.filter(option => option.input && option.input.checked).length; if (alreadySelectedCount > 0) { logger(`💡 \u9898\u76ee\u5df2\u6709 ${alreadySelectedCount} \u4e2a\u9009\u9879\u88ab\u9009\u4e2d,\u65e0\u9700\u91cd\u590d\u9009\u62e9`, 'blue'); // \u6dfb\u52a0\u6210\u529f\u72b6\u6001\u6307\u793a\u5668,\u56e0\u4e3a\u9898\u76ee\u5b9e\u9645\u4e0a\u5df2\u7ecf\u5b8c\u6210 const questionNumber = getCurrentQuestionNumber(); const actualQuestionText = getQuestionText(document.querySelector('.questionContent')) || '\u9898\u76ee\u5185\u5bb9\u83b7\u53d6\u5931\u8d25'; const selectedOptions = questionData.options .filter(option => option.input && option.input.checked) .map((option) => { const displayText = (option.content || option.text || option || '').toString().replace(/<[^>]*>/g, '').trim(); return `${String.fromCharCode(65 + questionData.options.indexOf(option))}. ${displayText}`; }) .join(', '); addQuestionStatusIndicator(questionNumber, 'success', { question: actualQuestionText, answer: answer, selected: selectedOptions, type: questionData.type === 0 ? '\u5355\u9009\u9898' : questionData.type === 1 ? '\u591a\u9009\u9898' : '\u5176\u4ed6', error: '\u9898\u76ee\u5df2\u5b8c\u6210,\u65e0\u9700\u91cd\u590d\u9009\u62e9' }); } else { logger('❌ \u672a\u627e\u5230\u5339\u914d\u7684\u9009\u9879', 'red'); logger('💡 \u63d0\u793a: \u8bf7\u68c0\u67e5\u7b54\u6848\u683c\u5f0f\u6216\u9898\u5e93\u6570\u636e\u51c6\u786e\u6027', 'blue'); // \u6dfb\u52a0\u5931\u8d25\u72b6\u6001\u6307\u793a\u5668 const questionNumber = getCurrentQuestionNumber(); const actualQuestionText = getQuestionText(document.querySelector('.questionContent')) || '\u9898\u76ee\u5185\u5bb9\u83b7\u53d6\u5931\u8d25'; addQuestionStatusIndicator(questionNumber, 'failed', { question: actualQuestionText, answer: answer, error: '\u672a\u627e\u5230\u9009\u9879\u6216,\u5df2\u7ecf\u7b54\u9898', type: questionData.type === 0 ? '\u5355\u9009\u9898' : questionData.type === 1 ? '\u591a\u9009\u9898' : '\u5176\u4ed6' }); } } } catch (error) { logger(`❌ \u9009\u62e9\u9009\u9879\u65f6\u51fa\u9519: ${error}`, 'red'); logger('💡 \u63d0\u793a: \u8bf7\u68c0\u67e5\u9875\u9762\u7ed3\u6784\u6216\u5237\u65b0\u9875\u9762\u91cd\u8bd5', 'blue'); } } // \u70b9\u51fb\u667a\u6167\u6811\u9009\u9879 function clickZhihuishuOption(option) { try { // \u5c1d\u8bd5\u591a\u79cd\u70b9\u51fb\u65b9\u5f0f if (option.input) { // \u65b9\u5f0f1:\u76f4\u63a5\u70b9\u51fbradio input option.input.click(); } else if (option.element) { // \u65b9\u5f0f2:\u70b9\u51fb\u9009\u9879\u5143\u7d20 option.element.click(); } // \u65b9\u5f0f3:\u89e6\u53d1change\u4e8b\u4ef6 if (option.input) { option.input.checked = true; const event = new Event('change', { bubbles: true }); option.input.dispatchEvent(event); } // \u4fee\u590d\u9009\u9879\u6587\u672c\u663e\u793a\u95ee\u9898 const displayText = (option.content || option.text || option || '').toString().replace(/<[^>]*>/g, '').trim(); logger(`\u6210\u529f\u70b9\u51fb\u9009\u9879: ${displayText.substring(0, 20)}...`, 'green'); } catch (error) { logger(`\u70b9\u51fb\u9009\u9879\u5931\u8d25: ${error}`, 'red'); } } // \u968f\u673a\u9009\u62e9\u529f\u80fd\u5df2\u5220\u9664 - \u6839\u636e\u7528\u6237\u8981\u6c42\u5b8c\u5168\u5220\u9664\u968f\u673a\u9009\u62e9\u529f\u80fd // \u521d\u59cb\u5316\u89c6\u9891\u4e13\u7528UI - \u7b80\u5316\u7248\u63a7\u5236\u9762\u677f,\u53ea\u5305\u542b\u89c6\u9891\u76f8\u5173\u529f\u80fd function initZhihuishuVideoUI() { logger('🎬 \u5f00\u59cb\u521d\u59cb\u5316\u89c6\u9891\u9875\u9762\u4e13\u7528\u63a7\u5236\u9762\u677f', 'blue'); // \u9632\u6b62\u91cd\u590d\u521b\u5efa if (document.getElementById('zhs-video-control-panel')) { logger('🎬 \u89c6\u9891\u63a7\u5236\u9762\u677f\u5df2\u5b58\u5728,\u8df3\u8fc7\u521b\u5efa', 'orange'); return; } try { const panel = document.createElement('div'); panel.id = 'zhs-video-control-panel'; // \u521b\u5efa\u6807\u9898\u680f const header = document.createElement('div'); header.style.cssText = ` background: #409EFF; color: white; padding: 12px 15px; border-radius: 8px 8px 0 0; font-weight: 500; display: flex; align-items: center; cursor: move; `; const logo = document.createElement('img'); logo.src = 'https://tk.mixuelo.cc/128.png'; logo.style.cssText = 'width: 20px; height: 20px; margin-right: 8px;border-radius: 50px;'; const title = document.createElement('span'); title.textContent = '\u667a\u6167\u6811\u89c6\u9891\u52a9\u624b'; header.appendChild(logo); header.appendChild(title); // \u521b\u5efa\u5185\u5bb9\u533a\u57df const content = document.createElement('div'); content.style.cssText = 'padding: 15px;'; // \u89c6\u9891\u63a7\u5236\u533a\u57df const videoControl = document.createElement('div'); videoControl.style.cssText = 'margin-bottom: 15px;'; videoControl.innerHTML = `
`; // \u64ad\u653e\u901f\u5ea6\u533a\u57df const speedControl = document.createElement('div'); speedControl.style.cssText = 'margin-bottom: 15px;'; speedControl.innerHTML = ` `; // \u72b6\u6001\u663e\u793a\u533a\u57df const statusArea = document.createElement('div'); statusArea.style.cssText = ` background: #f8f9fa; padding: 8px; border-radius: 4px; font-size: 12px; color: #666; `; statusArea.innerHTML = '
\u7b49\u5f85\u89c6\u9891\u52a0\u8f7d...
'; // \u7ec4\u88c5\u9762\u677f content.appendChild(videoControl); content.appendChild(speedControl); content.appendChild(statusArea); panel.appendChild(header); panel.appendChild(content); // \u8bbe\u7f6e\u9762\u677f\u6837\u5f0f panel.style.cssText = ` position: fixed; top: 20px; right: 20px; width: 280px; background: white; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 10000; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 13px; `; document.body.appendChild(panel); logger('🎬 \u89c6\u9891\u63a7\u5236\u9762\u677f\u5df2\u521b\u5efa\u5e76\u6dfb\u52a0\u5230\u9875\u9762', 'green'); // \u521d\u59cb\u5316\u4e8b\u4ef6\u76d1\u542c setTimeout(() => { initVideoControlEvents(); logger('🎬 \u89c6\u9891\u63a7\u5236\u4e8b\u4ef6\u5df2\u521d\u59cb\u5316', 'green'); }, 100); // \u4f7f\u9762\u677f\u53ef\u62d6\u62fd setTimeout(() => { makeVideoPanelDraggable(panel); logger('🎬 \u89c6\u9891\u9762\u677f\u62d6\u62fd\u529f\u80fd\u5df2\u542f\u7528', 'green'); }, 200); } catch (error) { logger(`🎬 \u89c6\u9891\u63a7\u5236\u9762\u677f\u521b\u5efa\u5931\u8d25: ${error.message}`, 'red'); } } // \u521d\u59cb\u5316\u89c6\u9891\u63a7\u5236\u4e8b\u4ef6 function initVideoControlEvents() { logger('🎬 \u5f00\u59cb\u521d\u59cb\u5316\u89c6\u9891\u63a7\u5236\u4e8b\u4ef6', 'blue'); try { // \u81ea\u52a8\u64ad\u653e\u89c6\u9891\u5f00\u5173 const autoVideoToggle = document.getElementById('zhs-auto-video'); if (autoVideoToggle) { autoVideoToggle.checked = localStorage.getItem('ZhsJsSetting.video') === 'true'; autoVideoToggle.addEventListener('change', (e) => { const isChecked = e.target.checked; localStorage.setItem('ZhsJsSetting.video', isChecked.toString()); setting.video = isChecked; logger(`🎬 \u81ea\u52a8\u64ad\u653e\u89c6\u9891\u5df2${isChecked ? '\u5f00\u542f' : '\u5173\u95ed'}`, isChecked ? 'green' : 'orange'); updateVideoStatus(`\u81ea\u52a8\u64ad\u653e: ${isChecked ? '\u5f00\u542f' : '\u5173\u95ed'}`); }); logger('🎬 \u81ea\u52a8\u64ad\u653e\u89c6\u9891\u5f00\u5173\u5df2\u521d\u59cb\u5316', 'green'); } else { logger('🎬 \u672a\u627e\u5230\u81ea\u52a8\u64ad\u653e\u89c6\u9891\u5f00\u5173\u5143\u7d20', 'orange'); } // \u81ea\u52a8\u4e0b\u4e00\u4e2a\u89c6\u9891\u5f00\u5173 const autoNextToggle = document.getElementById('zhs-auto-next'); if (autoNextToggle) { // \u9ed8\u8ba4\u5f00\u542f\u81ea\u52a8\u4e0b\u4e00\u4e2a\u89c6\u9891\u529f\u80fd autoNextToggle.checked = localStorage.getItem('ZhsJsSetting.jump') !== 'false'; localStorage.setItem('ZhsJsSetting.jump', autoNextToggle.checked.toString()); setting.jump = autoNextToggle.checked; autoNextToggle.addEventListener('change', (e) => { const isChecked = e.target.checked; localStorage.setItem('ZhsJsSetting.jump', isChecked.toString()); setting.jump = isChecked; logger(`🎬 \u81ea\u52a8\u4e0b\u4e00\u4e2a\u89c6\u9891\u5df2${isChecked ? '\u5f00\u542f' : '\u5173\u95ed'}`, isChecked ? 'green' : 'orange'); updateVideoStatus(`\u81ea\u52a8\u4e0b\u4e00\u4e2a: ${isChecked ? '\u5f00\u542f' : '\u5173\u95ed'}`); }); logger('🎬 \u81ea\u52a8\u4e0b\u4e00\u4e2a\u89c6\u9891\u5f00\u5173\u5df2\u521d\u59cb\u5316', 'green'); } else { logger('🎬 \u672a\u627e\u5230\u81ea\u52a8\u4e0b\u4e00\u4e2a\u89c6\u9891\u5f00\u5173\u5143\u7d20', 'orange'); } // \u64ad\u653e\u901f\u5ea6\u9009\u62e9 const speedSelect = document.getElementById('zhs-video-speed'); if (speedSelect) { speedSelect.addEventListener('change', (e) => { const speed = parseFloat(e.target.value); setVideoSpeed(speed); logger(`🎬 \u89c6\u9891\u64ad\u653e\u901f\u5ea6\u8bbe\u7f6e\u4e3a: ${speed}x`, 'blue'); updateVideoStatus(`\u64ad\u653e\u901f\u5ea6: ${speed}x`); }); logger('🎬 \u64ad\u653e\u901f\u5ea6\u9009\u62e9\u5df2\u521d\u59cb\u5316', 'green'); } else { logger('🎬 \u672a\u627e\u5230\u64ad\u653e\u901f\u5ea6\u9009\u62e9\u5143\u7d20', 'orange'); } // \u521d\u59cb\u5316\u72b6\u6001\u663e\u793a updateVideoStatus('\u89c6\u9891\u63a7\u5236\u9762\u677f\u5df2\u5c31\u7eea'); } catch (error) { logger(`🎬 \u89c6\u9891\u63a7\u5236\u4e8b\u4ef6\u521d\u59cb\u5316\u5931\u8d25: ${error.message}`, 'red'); } } // \u4f7f\u89c6\u9891\u9762\u677f\u53ef\u62d6\u62fd function makeVideoPanelDraggable(panel) { let isDragging = false; let currentX; let currentY; let initialX; let initialY; let xOffset = 0; let yOffset = 0; const header = panel.querySelector('div:first-child'); header.addEventListener('mousedown', dragStart); document.addEventListener('mousemove', drag); document.addEventListener('mouseup', dragEnd); function dragStart(e) { if (e.target.tagName === 'INPUT' || e.target.tagName === 'SELECT') return; initialX = e.clientX - xOffset; initialY = e.clientY - yOffset; if (e.target === header || header.contains(e.target)) { isDragging = true; panel.style.cursor = 'grabbing'; } } function drag(e) { if (isDragging) { e.preventDefault(); currentX = e.clientX - initialX; currentY = e.clientY - initialY; xOffset = currentX; yOffset = currentY; panel.style.transform = `translate(${currentX}px, ${currentY}px)`; } } function dragEnd() { initialX = currentX; initialY = currentY; isDragging = false; panel.style.cursor = 'move'; } } // \u66f4\u65b0\u89c6\u9891\u72b6\u6001\u663e\u793a function updateVideoStatus(status) { const statusDiv = document.getElementById('zhs-video-status'); if (statusDiv) { statusDiv.textContent = status; } } // \u8bbe\u7f6e\u89c6\u9891\u64ad\u653e\u901f\u5ea6 function setVideoSpeed(speed) { const videos = document.querySelectorAll('video'); videos.forEach(video => { video.playbackRate = speed; }); } // \u521d\u59cb\u5316\u89c6\u9891\u81ea\u52a8\u4e0b\u4e00\u4e2a\u529f\u80fd function initVideoAutoNext() { logger('🎬 \u521d\u59cb\u5316\u89c6\u9891\u81ea\u52a8\u4e0b\u4e00\u4e2a\u529f\u80fd', 'blue'); // \u76d1\u542c\u89c6\u9891\u64ad\u653e\u7ed3\u675f\u4e8b\u4ef6 const checkVideoEnd = () => { const videos = document.querySelectorAll('video'); videos.forEach(video => { if (!video.hasAttribute('data-auto-next-listener')) { video.setAttribute('data-auto-next-listener', 'true'); video.addEventListener('ended', () => { if (setting.jump) { logger('🎬 \u89c6\u9891\u64ad\u653e\u7ed3\u675f,\u51c6\u5907\u81ea\u52a8\u4e0b\u4e00\u4e2a', 'green'); updateVideoStatus('\u89c6\u9891\u64ad\u653e\u7ed3\u675f,\u51c6\u5907\u8df3\u8f6c...'); setTimeout(goToNextVideo, 2000); } }); logger(`🎬 \u5df2\u4e3a\u89c6\u9891\u6dfb\u52a0\u64ad\u653e\u7ed3\u675f\u76d1\u542c\u5668`, 'green'); } }); }; // \u5b9a\u671f\u68c0\u67e5\u65b0\u7684\u89c6\u9891\u5143\u7d20 setInterval(checkVideoEnd, 3000); checkVideoEnd(); // \u989d\u5916\u7684\u68c0\u6d4b\u673a\u5236:\u76d1\u542c\u4efb\u52a1\u70b9\u72b6\u6001\u53d8\u5316 const checkTaskStatus = () => { // \u68c0\u67e5\u5f53\u524d\u4efb\u52a1\u662f\u5426\u5df2\u5b8c\u6210(\u51fa\u73b0icon-finish) const currentActiveItem = document.querySelector('.file-item.active'); if (currentActiveItem) { const hasFinishIcon = currentActiveItem.querySelector('.icon-finish'); if (hasFinishIcon && setting.jump) { logger('🎬 \u68c0\u6d4b\u5230\u5f53\u524d\u4efb\u52a1\u5df2\u5b8c\u6210,\u51c6\u5907\u81ea\u52a8\u4e0b\u4e00\u4e2a', 'green'); updateVideoStatus('\u4efb\u52a1\u5df2\u5b8c\u6210,\u51c6\u5907\u8df3\u8f6c...'); setTimeout(goToNextVideo, 3000); } } }; // \u5b9a\u671f\u68c0\u67e5\u4efb\u52a1\u72b6\u6001 setInterval(checkTaskStatus, 5000); logger('🎬 \u89c6\u9891\u81ea\u52a8\u4e0b\u4e00\u4e2a\u529f\u80fd\u5df2\u542f\u52a8', 'green'); } // \u8df3\u8f6c\u5230\u4e0b\u4e00\u4e2a\u89c6\u9891 - \u6839\u636eicon-finish\u5143\u7d20\u5224\u65ad function goToNextVideo() { try { logger('\u5f00\u59cb\u67e5\u627e\u4e0b\u4e00\u4e2a\u672a\u5b8c\u6210\u7684\u89c6\u9891\u4efb\u52a1', 'blue'); // \u67e5\u627e\u6240\u6709\u89c6\u9891\u4efb\u52a1\u9879(\u5305\u542bicon-video\u7684\u5143\u7d20) const videoItems = document.querySelectorAll('.file-item'); let nextVideoItem = null; // \u904d\u5386\u6240\u6709\u4efb\u52a1\u9879,\u627e\u5230\u7b2c\u4e00\u4e2a\u6ca1\u6709icon-finish\u7684\u89c6\u9891\u4efb\u52a1 for (const item of videoItems) { const hasVideoIcon = item.querySelector('.icon-video'); const hasFinishIcon = item.querySelector('.icon-finish'); // \u5982\u679c\u662f\u89c6\u9891\u4efb\u52a1\u4e14\u6ca1\u6709\u5b8c\u6210\u6807\u8bb0 if (hasVideoIcon && !hasFinishIcon) { nextVideoItem = item; break; } } if (nextVideoItem) { const fileName = nextVideoItem.querySelector('.file-name')?.textContent || '\u672a\u77e5'; const fileId = nextVideoItem.id.replace('file_', ''); logger(`\u627e\u5230\u4e0b\u4e00\u4e2a\u672a\u5b8c\u6210\u7684\u89c6\u9891: ${fileName} (ID: ${fileId})`, 'green'); // \u70b9\u51fb\u8df3\u8f6c\u5230\u4e0b\u4e00\u4e2a\u89c6\u9891 nextVideoItem.click(); updateVideoStatus(`\u6b63\u5728\u8df3\u8f6c\u5230: ${fileName}`); // \u8bb0\u5f55\u8df3\u8f6c\u4fe1\u606f setTimeout(() => { logger(`\u5df2\u8df3\u8f6c\u5230\u89c6\u9891: ${fileName}`, 'green'); updateVideoStatus(`\u5f53\u524d\u89c6\u9891: ${fileName}`); }, 2000); } else { // \u6ca1\u6709\u627e\u5230\u672a\u5b8c\u6210\u7684\u89c6\u9891\uff0c\u67e5\u627e\u672a\u5b8c\u6210\u7684\u6587\u6863\u4efb\u52a1 for (const item of videoItems) { const hasDocIcon = item.querySelector('.icon-doc'); const hasFinishIcon = item.querySelector('.icon-finish'); if (hasDocIcon && !hasFinishIcon) { nextVideoItem = item; break; } } if (nextVideoItem) { const fileName = nextVideoItem.querySelector('.file-name')?.textContent || '\u672a\u77e5'; logger(`\u6240\u6709\u89c6\u9891\u5df2\u5b8c\u6210\uff0c\u8df3\u8f6c\u5230\u4e0b\u4e00\u4e2a\u6587\u6863\u4efb\u52a1: ${fileName}`, 'blue'); nextVideoItem.click(); updateVideoStatus(`\u8df3\u8f6c\u5230\u6587\u6863: ${fileName}`); } else { logger('\u6240\u6709\u4efb\u52a1\u5df2\u5b8c\u6210\uff01', 'green'); updateVideoStatus('\u6240\u6709\u4efb\u52a1\u5df2\u5b8c\u6210'); } } } catch (error) { logger(`\u81ea\u52a8\u4e0b\u4e00\u4e2a\u89c6\u9891\u5931\u8d25: ${error.message}`, 'red'); updateVideoStatus('\u81ea\u52a8\u4e0b\u4e00\u4e2a\u5931\u8d25'); } } // \u667a\u6167\u6811\u89c6\u9891\u63a7\u5236\u521d\u59cb\u5316 function initZhihuishuVideoControl() { logger('\ud83c\udfa6 \u521d\u59cb\u5316\u667a\u6167\u6811\u89c6\u9891\u63a7\u5236\u7cfb\u7edf', 'blue'); // \u5ef6\u8fdf\u6267\u884c\uff0c\u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u5b8c\u6210 setTimeout(() => { startZhihuishuVideoControl(); }, 2000); // \u5b9a\u671f\u68c0\u67e5\u65b0\u7684\u89c6\u9891\u5143\u7d20 setInterval(() => { startZhihuishuVideoControl(); }, 10000); logger('\ud83c\udfa6 \u89c6\u9891\u63a7\u5236\u7cfb\u7edf\u76d1\u542c\u5668\u5df2\u542f\u52a8', 'green'); } // \u5f00\u59cb\u667a\u6167\u6811\u89c6\u9891\u63a7\u5236 function startZhihuishuVideoControl() { try { // \u67e5\u627e\u89c6\u9891\u5143\u7d20 const videoElements = findZhihuishuVideoElements(); if (videoElements.length > 0) { logger(`\u53d1\u73b0 ${videoElements.length} \u4e2a\u89c6\u9891\u5143\u7d20\uff0c\u5f00\u59cb\u5904\u7406`, 'green'); videoElements.forEach((video, index) => { processZhihuishuVideo(video, index); }); } // \u67e5\u627fiframe\u4e2d\u7684\u89c6\u9891 const iframes = document.querySelectorAll('iframe'); iframes.forEach((iframe, index) => { try { const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; if (iframeDoc) { const iframeVideos = iframeDoc.querySelectorAll('video'); if (iframeVideos.length > 0) { logger(`\u5728iframe ${index + 1} \u4e2d\u53d1\u73b0 ${iframeVideos.length} \u4e2a\u89c6\u9891`, 'blue'); iframeVideos.forEach((video, videoIndex) => { processZhihuishuVideo(video, `iframe-${index}-${videoIndex}`); }); } } } catch (e) { // \u8de8\u57dfiframe\u65e0\u6cd5\u8bbf\u95ee\uff0c\u5ffd\u7565\u9519\u8bef } }); } catch (error) { logger(`\u89c6\u9891\u63a7\u5236\u51fa\u9519: ${error}`, 'red'); } } // \u67e5\u627e\u667a\u6167\u6811\u89c6\u9891\u5143\u7d20 function findZhihuishuVideoElements() { const selectors = [ 'video', // \u76f4\u63a5\u7684video\u6807\u7b7e '.video-player video', // \u89c6\u9891\u64ad\u653e\u5668\u4e2d\u7684video '.player-container video', // \u64ad\u653e\u5668\u5bb9\u5668\u4e2d\u7684video '[class*="video"] video', // \u5305\u542bvideo\u7c7b\u540d\u7684\u5bb9\u5668\u4e2d\u7684video '.vjs-tech', // Video.js\u6280\u672f\u5c42 ]; let videos = []; for (const selector of selectors) { const elements = document.querySelectorAll(selector); if (elements.length > 0) { videos = Array.from(elements); logger(`\u4f7f\u7528\u9009\u62e9\u5668 "${selector}" \u627e\u5230 ${elements.length} \u4e2a\u89c6\u9891`, 'blue'); break; } } return videos; } // \u5904\u7406\u667a\u6167\u6811\u89c6\u9891 function processZhihuishuVideo(video, index) { try { if (!video || video.zhsProcessed) { return; // \u907f\u514d\u91cd\u590d\u5904\u7406 } logger(`\u5904\u7406\u7b2c ${index + 1} \u4e2a\u89c6\u9891\u5143\u7d20`, 'blue'); // \u6807\u8bb0\u5df2\u5904\u7406 video.zhsProcessed = true; // \u8bbe\u7f6e\u89c6\u9891\u5c5e\u6027 setupZhihuishuVideoProperties(video); // \u81ea\u52a8\u64ad\u653e if (setting.video) { autoPlayZhihuishuVideo(video, index); } // \u76d1\u542c\u89c6\u9891\u4e8b\u4ef6 setupZhihuishuVideoEvents(video, index); } catch (error) { logger(`\u5904\u7406\u89c6\u9891 ${index + 1} \u65f6\u51fa\u9519: ${error}`, 'red'); } } // \u8bbe\u7f6e\u667a\u6167\u6811\u89c6\u9891\u5c5e\u6027 function setupZhihuishuVideoProperties(video) { try { // \u8bbe\u7f6e\u97f3\u91cf const volume = parseFloat(setting.vol) / 100; video.volume = volume; // \u8bbe\u7f6e\u9759\u97f3 video.muted = setting.vol == '0'; // \u8bbe\u7f6e\u500d\u901f const speed = parseFloat(setting.speed); if (speed > 0 && speed <= 16) { video.playbackRate = speed; logger(`\u89c6\u9891\u500d\u901f\u8bbe\u7f6e\u4e3a: ${speed}x`, 'blue'); } // \u5176\u4ed6\u5c5e\u6027\u8bbe\u7f6e video.controls = true; // \u663e\u793a\u63a7\u5236\u6761 video.preload = 'auto'; // \u9884\u52a0\u8f7d logger(`\u89c6\u9891\u5c5e\u6027\u8bbe\u7f6e\u5b8c\u6210 - \u97f3\u91cf: ${volume}, \u500d\u901f: ${speed}x, \u9759\u97f3: ${video.muted}`, 'blue'); } catch (error) { logger(`\u8bbe\u7f6e\u89c6\u9891\u5c5e\u6027\u65f6\u51fa\u9519: ${error}`, 'red'); } } // \u81ea\u52a8\u64ad\u653e\u667a\u6167\u6811\u89c6\u9891 function autoPlayZhihuishuVideo(video, index) { try { // \u5c1d\u8bd5\u64ad\u653e\u89c6\u9891 const playPromise = video.play(); if (playPromise !== undefined) { playPromise.then(() => { logger(`\u89c6\u9891 ${index + 1} \u5f00\u59cb\u64ad\u653e,\u500d\u901f: ${setting.speed}x`, 'green'); }).catch(error => { logger(`\u89c6\u9891 ${index + 1} \u81ea\u52a8\u64ad\u653e\u5931\u8d25: ${error.message}`, 'orange'); // \u5c1d\u8bd5\u7528\u6237\u4ea4\u4e92\u540e\u64ad\u653e setTimeout(() => { video.play().then(() => { logger(`\u89c6\u9891 ${index + 1} \u5ef6\u8fdf\u64ad\u653e\u6210\u529f`, 'green'); }).catch(e => { logger(`\u89c6\u9891 ${index + 1} \u5ef6\u8fdf\u64ad\u653e\u4e5f\u5931\u8d25: ${e.message}`, 'red'); }); }, 1000); }); } else { logger(`\u89c6\u9891 ${index + 1} \u64ad\u653e\u65b9\u6cd5\u4e0d\u652f\u6301Promise`, 'orange'); } } catch (error) { logger(`\u64ad\u653e\u89c6\u9891 ${index + 1} \u65f6\u51fa\u9519: ${error}`, 'red'); } } // \u8bbe\u7f6e\u667a\u6167\u6811\u89c6\u9891\u4e8b\u4ef6\u76d1\u542c function setupZhihuishuVideoEvents(video, index) { try { // \u64ad\u653e\u4e8b\u4ef6 video.addEventListener('play', () => { logger(`\u89c6\u9891 ${index + 1} \u5f00\u59cb\u64ad\u653e`, 'green'); }); // \u6682\u505c\u4e8b\u4ef6 video.addEventListener('pause', () => { logger(`\u89c6\u9891 ${index + 1} \u6682\u505c\u64ad\u653e`, 'orange'); // \u5982\u679c\u8bbe\u7f6e\u4e86\u81ea\u52a8\u64ad\u653e,\u5c1d\u8bd5\u7ee7\u7eed\u64ad\u653e if (setting.video && !video.ended) { setTimeout(() => { video.play().catch(e => { logger(`\u91cd\u65b0\u64ad\u653e\u89c6\u9891 ${index + 1} \u5931\u8d25: ${e.message}`, 'red'); }); }, 2000); } }); // \u7ed3\u675f\u4e8b\u4ef6 video.addEventListener('ended', () => { logger(`\u89c6\u9891 ${index + 1} \u64ad\u653e\u5b8c\u6210`, 'green'); }); // \u9519\u8bef\u4e8b\u4ef6 video.addEventListener('error', (e) => { logger(`\u89c6\u9891 ${index + 1} \u64ad\u653e\u9519\u8bef: ${e.message || '\u672a\u77e5\u9519\u8bef'}`, 'red'); }); // \u65f6\u95f4\u66f4\u65b0\u4e8b\u4ef6(\u7528\u4e8e\u663e\u793a\u8fdb\u5ea6) video.addEventListener('timeupdate', () => { if (video.duration > 0) { const progress = (video.currentTime / video.duration * 100).toFixed(1); // \u6bcf10%\u663e\u793a\u4e00\u6b21\u8fdb\u5ea6,\u907f\u514d\u65e5\u5fd7\u8fc7\u591a if (progress % 10 < 0.1) { logger(`\u89c6\u9891 ${index + 1} \u64ad\u653e\u8fdb\u5ea6: ${progress}%`, 'blue'); } } }); // \u52a0\u8f7d\u5b8c\u6210\u4e8b\u4ef6 video.addEventListener('loadeddata', () => { logger(`\u89c6\u9891 ${index + 1} \u6570\u636e\u52a0\u8f7d\u5b8c\u6210,\u65f6\u957f: ${video.duration.toFixed(1)}\u79d2`, 'blue'); }); } catch (error) { logger(`\u8bbe\u7f6e\u89c6\u9891\u4e8b\u4ef6\u76d1\u542c\u65f6\u51fa\u9519: ${error}`, 'red'); } } function hookHiexam() { var ajax = new xhr(); ajax.onload = function () { if (this.status != 200 || !this.responseURL.match('getDoQuestSingle')) return; var obj = JSON.parse(this.responseText).rt; $.each(obj.questionOptionList || [], function (index) { var $input = $('.TitleOptions-div input')[index]; if (obj.questionTypeId == 1) { this.isCorrect && setting.queue.push($input); } else if (obj.questionTypeId == 2) { this.isCorrect == $input.checked || setting.queue.push($input); } }); }; return ajax; } function filterStyle(dom, that) { var $dom = $(dom, that).clone().find('style').remove().end(); return $dom.find('img[src]').replaceWith(function () { return $('

').text(''); }).end().text().trim(); } // \u6dfb\u52a0\u5b57\u7b26\u4e32\u8f6c\u6362\u65b9\u6cd5 String.prototype.toCDB = function () { return this.replace(/[\uff01-\uff5e]/g, function (a) { return String.fromCharCode(a.charCodeAt(0) - 65248); }); }; // \u6dfb\u52a0\u667a\u6167\u6811API Key\u914d\u7f6e\u754c\u9762\u6837\u5f0f function addZhsConfigStyles() { if (document.getElementById('zhs-config-styles')) return; const style = document.createElement('style'); style.id = 'zhs-config-styles'; style.textContent = ` @keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } } .zhs-config-panel::-webkit-scrollbar { width: 6px; } .zhs-config-panel::-webkit-scrollbar-thumb { background: #409EFF; border-radius: 3px; } .zhs-config-panel::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); border-radius: 3px; } #zhs-control-panel::-webkit-scrollbar { width: 6px; } #zhs-control-panel::-webkit-scrollbar-thumb { background: #409EFF; border-radius: 3px; } #zhs-control-panel::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); border-radius: 3px; } #zhs-log-window::-webkit-scrollbar { width: 6px; } #zhs-log-window::-webkit-scrollbar-thumb { background: #409EFF; border-radius: 3px; } #zhs-log-window::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); border-radius: 3px; } .zhs-config-panel { position: fixed !important; top: 80px !important; right: 10px !important; width: 320px !important; max-height: 500px !important; overflow-y: auto !important; background: rgba(255, 255, 255, 0.98) !important; border-radius: 12px !important; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important; z-index: 2147483647 !important; padding: 20px !important; font-family: "Microsoft YaHei", sans-serif !important; transition: all 0.3s ease !important; border: 2px solid #409EFF !important; backdrop-filter: blur(10px) !important; } .zhs-config-header { text-align: center !important; margin-bottom: 20px !important; color: #409EFF !important; font-size: 18px !important; font-weight: bold !important; border-bottom: 2px solid #409EFF !important; padding-bottom: 10px !important; } .zhs-config-section { margin-bottom: 20px !important; padding: 15px !important; background: rgba(64, 158, 255, 0.05) !important; border-radius: 8px !important; border: 1px solid rgba(64, 158, 255, 0.2) !important; } .zhs-config-label { display: block !important; margin-bottom: 8px !important; color: #333 !important; font-weight: bold !important; font-size: 14px !important; } .zhs-config-input { width: 100% !important; padding: 10px !important; border: 2px solid #ddd !important; border-radius: 6px !important; font-size: 14px !important; transition: border-color 0.3s ease !important; box-sizing: border-box !important; } .zhs-config-input:focus { outline: none !important; border-color: #FC3D74 !important; box-shadow: 0 0 0 3px rgba(252, 61, 116, 0.1) !important; } .zhs-config-button { width: 100% !important; padding: 12px !important; background: linear-gradient(135deg, #409EFF, #337ecc) !important; color: white !important; border: none !important; border-radius: 6px !important; font-size: 14px !important; font-weight: bold !important; cursor: pointer !important; transition: all 0.3s ease !important; margin-top: 10px !important; } .zhs-config-button:hover { background: linear-gradient(135deg, #337ecc, #2b6cb0) !important; transform: translateY(-2px) !important; box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3) !important; } .zhs-config-message { margin-top: 10px !important; padding: 10px !important; border-radius: 6px !important; font-size: 13px !important; font-weight: bold !important; text-align: center !important; transition: all 0.3s ease !important; display: none !important; } .zhs-config-message.success { background: #4CAF50 !important; color: white !important; } .zhs-config-message.error { background: #f44336 !important; color: white !important; } .zhs-config-status { text-align: center !important; padding: 10px !important; border-radius: 6px !important; font-size: 13px !important; font-weight: bold !important; margin-bottom: 15px !important; } .zhs-config-status.configured { background: rgba(76, 175, 80, 0.1) !important; color: #4CAF50 !important; border: 1px solid rgba(76, 175, 80, 0.3) !important; } .zhs-config-status.not-configured { background: rgba(244, 67, 54, 0.1) !important; color: #f44336 !important; border: 1px solid rgba(244, 67, 54, 0.3) !important; } .zhs-config-close { position: absolute !important; top: 10px !important; right: 15px !important; background: none !important; border: none !important; font-size: 20px !important; color: #FC3D74 !important; cursor: pointer !important; width: 30px !important; height: 30px !important; border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important; transition: all 0.3s ease !important; } .zhs-config-close:hover { background: rgba(252, 61, 116, 0.1) !important; transform: rotate(90deg) !important; } .zhs-floating-button { position: fixed !important; bottom: 20px !important; right: 20px !important; width: 60px !important; height: 60px !important; background: linear-gradient(135deg, #409EFF, #337ecc) !important; border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important; color: white !important; font-size: 24px !important; cursor: pointer !important; box-shadow: 0 4px 20px rgba(64, 158, 255, 0.4) !important; transition: all 0.3s ease !important; z-index: 2147483646 !important; border: none !important; } .zhs-floating-button:hover { transform: scale(1.1) !important; box-shadow: 0 6px 25px rgba(64, 158, 255, 0.6) !important; } .zhs-status-indicator { position: absolute !important; top: -5px !important; right: -5px !important; width: 20px !important; height: 20px !important; border-radius: 50% !important; border: 2px solid white !important; font-size: 10px !important; display: flex !important; align-items: center !important; justify-content: center !important; } .zhs-status-indicator.configured { background: #4CAF50 !important; } .zhs-status-indicator.not-configured { background: #f44336 !important; animation: pulse 2s infinite !important; } @keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } } `; document.head.appendChild(style); } // \u521b\u5efa\u667a\u6167\u6811API Key\u914d\u7f6e\u754c\u9762 function createZhsConfigPanel() { // \u9632\u6b62\u91cd\u590d\u521b\u5efa if (document.getElementById('zhs-config-panel')) return; // \u6dfb\u52a0\u6837\u5f0f addZhsConfigStyles(); // \u83b7\u53d6\u5f53\u524d\u914d\u7f6e\u72b6\u6001 const currentKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const isConfigured = !!currentKey; // \u521b\u5efa\u914d\u7f6e\u9762\u677f const panel = document.createElement('div'); panel.id = 'zhs-config-panel'; panel.className = 'zhs-config-panel'; panel.innerHTML = `
🌟 \u667a\u6167\u6811\u7f51\u8bfe\u514d\u8d39\u52a9\u624b\u914d\u7f6e
${isConfigured ? '✅ API Key \u5df2\u914d\u7f6e' : '⚠️ \u8bf7\u914d\u7f6e API Key'}
💡 \u63d0\u793a:\u8bf7\u8f93\u5165\u6709\u6548\u7684\u9898\u5e93API Key\u4ee5\u4f7f\u7528\u9898\u5e93\u529f\u80fd
⚠️ \u91cd\u8981:\u5173\u95ed\u6b64\u9009\u9879\u5c06\u505c\u6b62\u6240\u6709\u81ea\u52a8\u7b54\u9898\u529f\u80fd
\u4f18\u5148\u7ea7\u987a\u5e8f:\u4e3b\u9898\u5e93 → AI\u7b54\u9898
📋 \u4f7f\u7528\u8bf4\u660e:
• \u914d\u7f6eAPI Key\u540e\u53ef\u81ea\u52a8\u83b7\u53d6\u6b63\u786e\u7b54\u6848
• \u652f\u6301\u591a\u5c42\u5907\u7528\u65b9\u6848\u786e\u4fdd\u7b54\u9898\u8fde\u7eed\u6027
• \u6309F9\u6216\u70b9\u51fb\u6d6e\u52a8\u6309\u94ae\u53ef\u5feb\u901f\u6253\u5f00\u914d\u7f6e
• \u6240\u6709\u914d\u7f6e\u5c06\u5b89\u5168\u5b58\u50a8\u5728\u672c\u5730\u6d4f\u89c8\u5668\u4e2d
\u667a\u6167\u6811\u81ea\u52a8\u7b54\u9898\u52a9\u624b v2.0
\u652f\u6301\u81ea\u52a8\u7b54\u9898、\u89c6\u9891\u64ad\u653e\u7b49\u529f\u80fd
`; document.body.appendChild(panel); // \u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\u5668(\u57fa\u4e8exxt.js\u7684\u6700\u4f73\u5b9e\u8df5) setupZhsConfigPanelEvents(panel); // \u6dfb\u52a0\u62d6\u62fd\u529f\u80fd makeZhsPanelDraggable(panel); } // \u4fdd\u5b58API Key function saveZhsApiKey() { const keyInput = document.getElementById('zhs-api-key'); const messageDiv = document.getElementById('zhs-config-message'); const key = keyInput.value.trim(); if (!key) { showZhsMessage('\u8bf7\u8f93\u5165API Key!', 'error'); return; } // \u663e\u793a\u9a8c\u8bc1\u4e2d\u72b6\u6001 showZhsMessage('\u6b63\u5728\u9a8c\u8bc1API Key...', 'info'); // \u53d1\u9001\u9a8c\u8bc1\u8bf7\u6c42 GM_xmlhttpRequest({ method: "POST", url: API_BASE_URL + "?act=verify_key", headers: { "Content-Type": "application/x-www-form-urlencoded" }, data: "key=" + encodeURIComponent(key), timeout: 10000, onload: function (response) { try { if (response.status === 200) { const result = JSON.parse(response.responseText); if (result.code === 1) { // \u9a8c\u8bc1\u6210\u529f,\u4fdd\u5b58key localStorage.setItem('GPTJsSetting.key', key); localStorage.setItem('tiku_key', key); showZhsMessage('✅ API Key \u9a8c\u8bc1\u6210\u529f\u5e76\u5df2\u4fdd\u5b58!', 'success'); logger('API Key \u914d\u7f6e\u6210\u529f', 'green'); // \u66f4\u65b0\u72b6\u6001\u663e\u793a updateZhsConfigStatus(true); updateZhsFloatingButton(); } else { showZhsMessage('❌ Key\u4e0d\u5b58\u5728,\u8bf7\u524d\u5f80\u871c\u96ea\u6fc0\u6d3b', 'error'); } } else { showZhsMessage('❌ \u9a8c\u8bc1\u8bf7\u6c42\u5931\u8d25,\u72b6\u6001\u7801: ' + response.status, 'error'); } } catch (e) { showZhsMessage('❌ \u9a8c\u8bc1\u54cd\u5e94\u89e3\u6790\u5931\u8d25: ' + e.message, 'error'); } }, onerror: function () { showZhsMessage('❌ \u7f51\u7edc\u8bf7\u6c42\u5931\u8d25,\u8bf7\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5', 'error'); }, ontimeout: function () { showZhsMessage('❌ \u8bf7\u6c42\u8d85\u65f6,\u8bf7\u7a0d\u540e\u91cd\u8bd5', 'error'); } }); } // \u7acb\u5373\u58f0\u660e\u5168\u5c40\u51fd\u6570(\u5728HTML\u521b\u5efa\u4e4b\u524d) window.saveZhsApiKey = saveZhsApiKey; // \u8bbe\u7f6e\u914d\u7f6e\u9762\u677f\u4e8b\u4ef6\u76d1\u542c\u5668 - \u57fa\u4e8exxt.js\u7684\u6700\u4f73\u5b9e\u8df5 function setupZhsConfigPanelEvents(panel) { try { // \u4fdd\u5b58\u6309\u94ae\u4e8b\u4ef6 const saveBtn = panel.querySelector('#zhs-save-btn'); if (saveBtn) { saveBtn.addEventListener('click', function (e) { e.preventDefault(); saveZhsApiKey(); }); } // \u5173\u95ed\u6309\u94ae\u4e8b\u4ef6 const closeBtn = panel.querySelector('#zhs-close-btn'); if (closeBtn) { closeBtn.addEventListener('click', function (e) { e.preventDefault(); closeZhsConfigPanel(); }); } // \u8f93\u5165\u6846\u56de\u8f66\u4e8b\u4ef6 const keyInput = panel.querySelector('#zhs-api-key'); if (keyInput) { keyInput.addEventListener('keypress', function (e) { if (e.key === 'Enter') { e.preventDefault(); saveZhsApiKey(); } }); } // API Key\u8f93\u5165\u4e8b\u4ef6 - \u57fa\u4e8exxt.js\u7684key\u7ba1\u7406 const apiKeyInput = panel.querySelector('#zhs-api-key'); if (apiKeyInput) { apiKeyInput.addEventListener('input', function (e) { const key = e.target.value.trim(); localStorage.setItem('GPTJsSetting.key', key); localStorage.setItem('tiku_key', key); // \u540c\u6b65\u5230tiku_key if (key) { logger('API Key\u5df2\u66f4\u65b0: ' + key.substring(0, 3) + '***' + key.substring(key.length - 3), 'green'); } else { logger('API Key\u5df2\u6e05\u7a7a', 'orange'); } }); } // \u624b\u52a8\u5f00\u542f\u7b54\u9898\u529f\u80fd\u914d\u7f6e\u4e8b\u4ef6 - \u57fa\u4e8exxt.js\u7684work\u8bbe\u7f6e const workCheckbox = panel.querySelector('#zhs-work'); if (workCheckbox) { workCheckbox.addEventListener('change', function (e) { const isEnabled = e.target.checked; localStorage.setItem('GPTJsSetting.work', isEnabled.toString()); setting.work = isEnabled ? 1 : 0; // \u540c\u6b65\u5230setting\u5bf9\u8c61 logger('\u81ea\u52a8\u7b54\u9898\u529f\u80fd\u5df2' + (isEnabled ? '\u5f00\u542f' : '\u5173\u95ed'), isEnabled ? 'green' : 'red'); // \u5982\u679c\u5173\u95ed\u4e86\u81ea\u52a8\u7b54\u9898\u529f\u80fd,\u663e\u793a\u63d0\u793a if (!isEnabled) { showZhsMessage('⚠️ \u81ea\u52a8\u7b54\u9898\u529f\u80fd\u5df2\u5173\u95ed,\u9700\u8981\u624b\u52a8\u5f00\u542f\u624d\u80fd\u7ee7\u7eed\u7b54\u9898', 'warning'); } else { showZhsMessage('✅ \u81ea\u52a8\u7b54\u9898\u529f\u80fd\u5df2\u5f00\u542f,\u7cfb\u7edf\u5c06\u81ea\u52a8\u5904\u7406\u9898\u76ee', 'success'); } }); } // \u9898\u5e93API\u914d\u7f6e\u4e8b\u4ef6 - \u4fee\u590d\u914d\u7f6e\u4fdd\u5b58\u95ee\u9898 const useTikuCheckbox = panel.querySelector('#zhs-use-tiku'); if (useTikuCheckbox) { useTikuCheckbox.addEventListener('change', function (e) { const isChecked = e.target.checked; localStorage.setItem('GPTJsSetting.useTiku', isChecked.toString()); logger('\u9898\u5e93API\u914d\u7f6e\u5df2\u66f4\u65b0: ' + isChecked, 'blue'); // \u7acb\u5373\u540c\u6b65\u5230\u754c\u9762\u663e\u793a setTimeout(() => { const checkbox = document.querySelector('#zhs-use-tiku'); if (checkbox) { checkbox.checked = isChecked; } }, 100); }); } // AI\u7b54\u9898\u914d\u7f6e\u4e8b\u4ef6 - \u4fee\u590d\u914d\u7f6e\u4fdd\u5b58\u95ee\u9898 const useAICheckbox = panel.querySelector('#zhs-use-ai'); if (useAICheckbox) { useAICheckbox.addEventListener('change', function (e) { const isChecked = e.target.checked; localStorage.setItem('GPTJsSetting.useAI', isChecked.toString()); logger('AI\u7b54\u9898\u914d\u7f6e\u5df2\u66f4\u65b0: ' + isChecked, 'blue'); // \u7acb\u5373\u540c\u6b65\u5230\u754c\u9762\u663e\u793a setTimeout(() => { const checkbox = document.querySelector('#zhs-use-ai'); if (checkbox) { checkbox.checked = isChecked; } }, 100); }); } logger('\u914d\u7f6e\u9762\u677f\u4e8b\u4ef6\u76d1\u542c\u5668\u8bbe\u7f6e\u5b8c\u6210', 'green'); } catch (e) { logger(`\u8bbe\u7f6e\u914d\u7f6e\u9762\u677f\u4e8b\u4ef6\u76d1\u542c\u5668\u5931\u8d25: ${e.message}`, 'red'); } } // \u663e\u793a\u6d88\u606f function showZhsMessage(message, type) { const messageDiv = document.getElementById('zhs-config-message'); if (!messageDiv) return; messageDiv.textContent = message; messageDiv.className = 'zhs-config-message ' + type; messageDiv.style.display = 'block'; // 3\u79d2\u540e\u81ea\u52a8\u9690\u85cf setTimeout(() => { messageDiv.style.display = 'none'; }, 3000); } // \u66f4\u65b0\u914d\u7f6e\u72b6\u6001\u663e\u793a function updateZhsConfigStatus(isConfigured) { const statusDiv = document.querySelector('.zhs-config-status'); if (statusDiv) { statusDiv.className = `zhs-config-status ${isConfigured ? 'configured' : 'not-configured'}`; statusDiv.textContent = isConfigured ? '✅ API Key \u5df2\u914d\u7f6e' : '⚠️ \u8bf7\u914d\u7f6e API Key'; } } // \u5173\u95ed\u914d\u7f6e\u9762\u677f function closeZhsConfigPanel() { const panel = document.getElementById('zhs-config-panel'); if (panel) { panel.remove(); } } // \u7acb\u5373\u58f0\u660e\u5168\u5c40\u51fd\u6570 window.closeZhsConfigPanel = closeZhsConfigPanel; // \u4f7f\u9762\u677f\u53ef\u62d6\u62fd function makeZhsPanelDraggable(panel) { let isDragging = false; let currentX; let currentY; let initialX; let initialY; let xOffset = 0; let yOffset = 0; panel.addEventListener('mousedown', dragStart); document.addEventListener('mousemove', drag); document.addEventListener('mouseup', dragEnd); function dragStart(e) { // \u6392\u9664\u6240\u6709\u4ea4\u4e92\u5143\u7d20,\u9632\u6b62\u62d6\u62fd\u5e72\u6270\u6b63\u5e38\u4ea4\u4e92 const interactiveElements = ['INPUT', 'BUTTON', 'TEXTAREA', 'SELECT', 'OPTION', 'A']; if (interactiveElements.includes(e.target.tagName)) return; // \u6392\u9664\u5177\u6709\u7279\u5b9aID\u7684\u5143\u7d20(AI\u52a9\u624b\u9762\u677f\u5185\u7684\u6240\u6709\u5143\u7d20) if (e.target.id && (e.target.id.startsWith('zhs-ai-') || e.target.closest('#zhs-tab-ai'))) return; // \u53ea\u5141\u8bb8\u5728\u6807\u9898\u680f\u6216\u7a7a\u767d\u533a\u57df\u62d6\u62fd const isHeaderArea = e.target.classList.contains('zhs-tab-header') || e.target.closest('.zhs-tab-header') || (e.target === panel && !e.target.closest('.zhs-tab-panel')); if (!isHeaderArea) return; initialX = e.clientX - xOffset; initialY = e.clientY - yOffset; if (e.target === panel || panel.contains(e.target)) { isDragging = true; panel.style.cursor = 'grabbing'; } } function drag(e) { if (isDragging) { e.preventDefault(); currentX = e.clientX - initialX; currentY = e.clientY - initialY; xOffset = currentX; yOffset = currentY; panel.style.transform = `translate(${currentX}px, ${currentY}px)`; } } function dragEnd() { initialX = currentX; initialY = currentY; isDragging = false; panel.style.cursor = 'move'; } } // \u667a\u6167\u6811\u9898\u5e93API\u8c03\u7528\u51fd\u6570 function zhsGetAnswerFromAPI(questionText, questionType, optionList) { try { // \u79fb\u9664\u81ea\u52a8\u7b54\u9898\u529f\u80fd\u68c0\u67e5 - \u9ed8\u8ba4\u603b\u662f\u7b54\u9898 // if (localStorage.getItem('GPTJsSetting.work') !== 'true') { // logger('\u81ea\u52a8\u7b54\u9898\u529f\u80fd\u5df2\u5173\u95ed,\u8df3\u8fc7\u5f53\u524d\u9898\u76ee', 'orange'); // return; // } // \u83b7\u53d6\u7528\u6237token,\u4f7f\u7528\u4e0exxt.js\u76f8\u540c\u7684\u65b9\u5f0f var userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || setting.token || ''; // \u4e25\u683c\u68c0\u67e5key\u662f\u5426\u6709\u6548 if (!userKey || userKey.trim() === '' || userKey === '1') { logger('\u672a\u8bbe\u7f6e\u6709\u6548\u7684API Key,\u65e0\u6cd5\u8c03\u7528\u9898\u5e93API', 'orange'); // \u542f\u52a8\u5907\u7528\u65b9\u6848 zhsHandleAPIFailure(questionText, questionType, optionList); return; } logger('\u5f00\u59cb\u8c03\u7528\u9898\u5e93API\u67e5\u8be2\u7b54\u6848...', 'blue'); // \u6784\u5efa\u9009\u9879\u6587\u672c var optionsText = ''; if (optionList && optionList.length > 0) { optionsText = optionList.map(function (option, index) { var label = String.fromCharCode(65 + index); // A, B, C, D... return label + '.' + option.content.replace(/<[^>]*>/g, '').trim(); }).join('\n'); } // \u9898\u578b\u6620\u5c04 var typeMapping = { 1: '\u5355\u9009\u9898', 2: '\u591a\u9009\u9898', 3: '\u586b\u7a7a\u9898', 4: '\u95ee\u7b54\u9898', 14: '\u5224\u65ad\u9898' }; var mappedType = typeMapping[questionType] || '\u5355\u9009\u9898'; // \u6784\u5efa\u8bf7\u6c42\u6570\u636e var requestData = "key=" + encodeURIComponent(userKey) + "&question=" + encodeURIComponent(questionText) + "&type=" + encodeURIComponent(mappedType); if (optionsText) { requestData += "&options=" + encodeURIComponent(optionsText); } // \u68c0\u67e5\u9898\u5e93API\u662f\u5426\u5f00\u542f if (localStorage.getItem('GPTJsSetting.useTiku') !== 'true') { logger('\u9898\u5e93API\u5df2\u7981\u7528,\u8df3\u8fc7\u9898\u5e93\u67e5\u8be2', 'orange'); zhsHandleAPIFailure(questionText, questionType, optionList); return; } // \u4f7f\u7528\u4e0exxt.js\u5b8c\u5168\u76f8\u540c\u7684API\u5730\u5740 const API_BASE_URL = (() => { const baseUrl = "tk.mixuelo.cc/api.php"; const protocol = window.location.protocol; if (protocol === 'https:') { return "https://" + baseUrl; } else { return "http://" + baseUrl; } })(); logger('\u53d1\u9001\u9898\u5e93API\u8bf7\u6c42...', 'blue'); logger(`\u4f7f\u7528API Key: ${userKey.substring(0, 8)}...`, 'blue'); logger(`\u9898\u5e93API\u72b6\u6001: ${localStorage.getItem('GPTJsSetting.useTiku')}`, 'blue'); logger(`\u8bf7\u6c42URL: ${API_BASE_URL}?act=query`, 'blue'); logger(`\u8bf7\u6c42\u6570\u636e: ${requestData.substring(0, 200)}...`, 'blue'); GM_xmlhttpRequest({ method: "POST", url: API_BASE_URL + "?act=query", headers: { "Content-Type": "application/x-www-form-urlencoded", "Cookie": "PHPSESSID=th9rcnfi47nl9fhjsjrcbmvq01" // \u6dfb\u52a0Cookie\u5934\u90e8,API Key\u901a\u8fc7data\u53c2\u6570\u4f20\u9012 }, data: requestData, timeout: 30000, // \u4fee\u590d\u4e3b\u9898\u5e93\u67e5\u8be2\u95ee\u9898 - \u7edf\u4e00\u8d85\u65f6\u65f6\u95f4\u523030\u79d2 onload: function (response) { try { if (response.status === 200) { var result = JSON.parse(response.responseText); if (result.code === 1 && result.data) { logger(`\u9898\u5e93API\u8fd4\u56de\u7b54\u6848: ${result.data}`, 'green'); const success = zhsProcessAnswer(result.data, questionType, optionList); if (success) { // \u53ea\u5728\u7b54\u9898\u6210\u529f\u540e\u6dfb\u52a0\u72b6\u6001\u6307\u793a\u5668 const currentQuestionNum = getCurrentQuestionNumber(); addQuestionStatusIndicator(currentQuestionNum, 'success', { question: questionText, answer: result.data, selectedOptions: result.data, type: '\u9898\u5e93\u7b54\u9898' }); } } else { logger(`\u9898\u5e93API\u8fd4\u56de\u9519\u8bef: ${result.msg || '\u672a\u77e5\u9519\u8bef'}`, 'orange'); // \u6dfb\u52a0\u5931\u8d25\u72b6\u6001\u6307\u793a\u5668 const currentQuestionNum = getCurrentQuestionNumber(); addQuestionStatusIndicator(currentQuestionNum, 'failed', { question: questionText, answer: '\u9898\u5e93API\u5931\u8d25', selectedOptions: '\u65e0', type: '\u9898\u5e93API\u9519\u8bef' }); // \u542f\u52a8\u5907\u7528\u65b9\u6848 zhsHandleAPIFailure(questionText, questionType, optionList); } } else { logger(`\u9898\u5e93API\u8bf7\u6c42\u5931\u8d25,\u72b6\u6001\u7801: ${response.status}`, 'red'); // \u6dfb\u52a0\u5931\u8d25\u72b6\u6001\u6307\u793a\u5668 const currentQuestionNum = getCurrentQuestionNumber(); addQuestionStatusIndicator(currentQuestionNum, 'failed', { question: questionText, answer: '\u9898\u5e93API\u8bf7\u6c42\u5931\u8d25', selectedOptions: '\u65e0', type: `HTTP\u9519\u8bef${response.status}` }); // \u542f\u52a8\u5907\u7528\u65b9\u6848 zhsHandleAPIFailure(questionText, questionType, optionList); } } catch (e) { logger(`\u89e3\u6790\u9898\u5e93API\u54cd\u5e94\u5931\u8d25: ${e.message}`, 'red'); // \u542f\u52a8\u5907\u7528\u65b9\u6848 zhsHandleAPIFailure(questionText, questionType, optionList); } }, onerror: function () { logger('\u9898\u5e93API\u8bf7\u6c42\u7f51\u7edc\u9519\u8bef', 'red'); // \u542f\u52a8\u5907\u7528\u65b9\u6848 zhsHandleAPIFailure(questionText, questionType, optionList); }, ontimeout: function () { logger('\u9898\u5e93API\u8bf7\u6c42\u8d85\u65f6(30\u79d2)', 'red'); // \u6dfb\u52a0\u5931\u8d25\u72b6\u6001\u6307\u793a\u5668 const currentQuestionNum = getCurrentQuestionNumber(); addQuestionStatusIndicator(currentQuestionNum, 'failed', { question: questionText, answer: '\u9898\u5e93API\u8d85\u65f6', selectedOptions: '\u65e0', type: '\u7f51\u7edc\u8d85\u65f6' }); // \u542f\u52a8\u5907\u7528\u65b9\u6848 zhsHandleAPIFailure(questionText, questionType, optionList); } }); } catch (e) { logger(`\u9898\u5e93API\u8c03\u7528\u5f02\u5e38: ${e.message}`, 'red'); // \u542f\u52a8\u5907\u7528\u65b9\u6848 zhsHandleAPIFailure(questionText, questionType, optionList); } } // \u5904\u7406API\u5931\u8d25\u7684\u5b8c\u6574\u5907\u7528\u65b9\u6848 - \u5b8c\u5168\u57fa\u4e8exxt.js\u67b6\u6784 function zhsHandleAPIFailure(questionText, questionType, optionList) { return new Promise((resolve, reject) => { // \u4e25\u683c\u68c0\u67e5API Key - \u8fd9\u662f\u5907\u7528\u65b9\u6848\u7684\u9a8c\u8bc1\u70b9 const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u6709\u6548\u7684key,\u4e14\u5f00\u542f\u4e86\u9700\u8981key\u7684\u529f\u80fd,\u5219\u5b8c\u5168\u62d2\u7edd\u5907\u7528\u65b9\u6848 if (!userKey || userKey.trim() === '' || userKey === '1') { if (useAI || useTiku) { logger('❌ \u672a\u914d\u7f6e\u6709\u6548Key,\u65e0\u6cd5\u4f7f\u7528\u4efb\u4f55\u7b54\u9898\u529f\u80fd', 'red'); logger('💡 \u63d0\u793a: \u8bf7\u5148\u914d\u7f6e\u6709\u6548\u7684API Key', 'orange'); reject('\u672a\u914d\u7f6e\u6709\u6548Key'); return; } } logger('\u542f\u52a8\u7b54\u9898\u5907\u7528\u65b9\u6848...', 'orange'); // \u8c03\u8bd5:\u68c0\u67e5\u5f53\u524d\u914d\u7f6e\u72b6\u6001 // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664 logger(`\u5f53\u524d\u914d\u7f6e\u72b6\u6001: AI\u7b54\u9898=${useAI}`, 'blue'); // \u7b2c\u4e00\u5907\u7528\u65b9\u6848:AI\u7b54\u9898 - \u5b8c\u5168\u57fa\u4e8exxt.js\u7684\u4f18\u5148\u7ea7\u673a\u5236 if (localStorage.getItem('GPTJsSetting.useAI') === 'true') { logger('\u5df2\u5f00\u542fAI\u7b54\u9898\u529f\u80fd,\u51c6\u5907\u83b7\u53d6AI\u7b54\u6848...', '#1890ff'); // \u9898\u578b\u6620\u5c04 var typeMapping = { 0: '\u5355\u9009\u9898', 1: '\u5355\u9009\u9898', 2: '\u591a\u9009\u9898', 3: '\u586b\u7a7a\u9898', 4: '\u95ee\u7b54\u9898', 14: '\u5224\u65ad\u9898' }; var typeName = typeMapping[questionType] || '\u5355\u9009\u9898'; // \u8bbe\u7f6eAI\u7b54\u9898\u8d85\u65f6\u4fdd\u62a4 var aiTimeout = setTimeout(() => { logger('❌ AI\u7b54\u9898\u7cfb\u7edf\u54cd\u5e94\u8d85\u65f6', 'red'); logger('💡 \u63d0\u793a: \u8bf7\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u6216AI\u670d\u52a1\u72b6\u6001', 'blue'); }, 30000); // 30\u79d2\u8d85\u65f6 // \u4e3aAI\u6784\u5efa\u5b8c\u6574\u7684\u9898\u76ee\u4fe1\u606f(\u9898\u578b+\u9898\u76ee+\u9009\u9879)- \u4fee\u590dAI\u6ca1\u6709\u6536\u5230\u9009\u9879\u4fe1\u606f\u7684\u95ee\u9898 let aiQuestionText = ''; if (typeName) { aiQuestionText += typeName + ': '; } aiQuestionText += questionText; // \u6dfb\u52a0\u9009\u9879\u4fe1\u606f if (optionList && optionList.length > 0) { aiQuestionText += '\n\u9009\u9879:\n'; optionList.forEach((option, index) => { const optionLabel = String.fromCharCode(65 + index); // A, B, C, D // \u4fee\u590d\u9009\u9879\u4fe1\u606f\u4f20\u9012\u95ee\u9898 - \u786e\u4fdd\u63d0\u53d6\u5b9e\u9645\u7684\u9009\u9879\u6587\u672c const optionText = option.content ? option.content.replace(/<[^>]*>/g, '').trim() : option.text ? option.text.trim() : (typeof option === 'string' ? option : String(option)); aiQuestionText += `${optionLabel}. ${optionText}\n`; }); } logger(`🤖 \u53d1\u9001\u7ed9AI\u7684\u5b8c\u6574\u9898\u76ee\u4fe1\u606f: ${aiQuestionText.substring(0, 200)}...`, 'blue'); logger(`🤖 \u9898\u578b: ${typeName}`, 'blue'); logger(`🤖 \u9009\u9879\u6570\u91cf: ${optionList ? optionList.length : 0}`, 'blue'); if (optionList && optionList.length > 0) { logger(`🤖 \u9009\u9879\u8be6\u60c5: ${JSON.stringify(optionList.slice(0, 2))}`, 'blue'); } zhsGetAIAnswer(aiQuestionText, typeName) .then(aiAnswer => { clearTimeout(aiTimeout); logger('AI\u6210\u529f\u56de\u7b54,\u7ee7\u7eed\u5904\u7406...', 'green'); const success = zhsProcessAnswer(aiAnswer, questionType, optionList); if (success) { logger('✅ AI\u7b54\u9898\u6210\u529f,\u51c6\u5907\u81ea\u52a8\u4e0b\u4e00\u9898', 'green'); // \u53ea\u5728\u7b54\u9898\u6210\u529f\u540e\u6dfb\u52a0\u72b6\u6001\u6307\u793a\u5668 const currentQuestionNum = getCurrentQuestionNumber(); addQuestionStatusIndicator(currentQuestionNum, 'success', { question: questionText, answer: aiAnswer, selectedOptions: aiAnswer, type: 'AI\u7b54\u9898' }); // \u8bbe\u7f6e\u5bfc\u822a\u6807\u8bb0\u5e76\u7acb\u5373\u5c1d\u8bd5\u5bfc\u822a - \u4f46\u9700\u8981\u518d\u6b21\u9a8c\u8bc1key const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; if (userKey && userKey.trim() !== '' && userKey !== '1') { setting.shouldNavigateNext = true; setTimeout(() => { zhsContinueToNextQuestion(); }, 1500); } else { logger('⚠️ \u672a\u914d\u7f6e\u6709\u6548Key,\u4e0d\u81ea\u52a8\u8df3\u9898,\u8bf7\u624b\u52a8\u5904\u7406', 'orange'); } } }) .catch(error => { clearTimeout(aiTimeout); logger('❌ AI\u56de\u7b54\u5931\u8d25: ' + error, 'red'); logger('💡 \u63d0\u793a: \u8bf7\u68c0\u67e5AI\u914d\u7f6e\u6216\u7f51\u7edc\u8fde\u63a5', 'blue'); // AI\u5931\u8d25\u540e\u4e0d\u518d\u4f7f\u7528\u968f\u673a\u7b54\u9898,\u76f4\u63a5\u62a5\u9519 const currentQuestionNum = getCurrentQuestionNumber(); addQuestionStatusIndicator(currentQuestionNum, 'failed', { question: questionText, answer: 'AI\u7b54\u9898\u5931\u8d25', selectedOptions: '\u65e0', type: 'AI\u7b54\u9898\u5931\u8d25' }); }); } else { // AI\u7b54\u9898\u529f\u80fd\u672a\u5f00\u542f logger('❌ AI\u7b54\u9898\u529f\u80fd\u672a\u5f00\u542f,\u65e0\u6cd5\u83b7\u53d6\u7b54\u6848', 'red'); logger('💡 \u63d0\u793a: \u8bf7\u5728\u8bbe\u7f6e\u4e2d\u5f00\u542fAI\u7b54\u9898\u529f\u80fd', 'blue'); } }); } // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664 - \u6839\u636e\u7528\u6237\u8981\u6c42\u5b8c\u5168\u5220\u9664\u968f\u673a\u7b54\u9898\u529f\u80fd // \u539f\u59cb\u7b54\u9898\u7cfb\u7edf\u7684\u5907\u7528\u65b9\u6848\u5904\u7406 - \u57fa\u4e8exxt.js\u67b6\u6784 function zhsHandleAPIFailureForOriginal(questionData) { logger('\u542f\u52a8\u539f\u59cb\u7b54\u9898\u7cfb\u7edf\u5907\u7528\u65b9\u6848...', 'orange'); // \u7b2c\u4e00\u5907\u7528\u65b9\u6848:AI\u7b54\u9898 if (localStorage.getItem('GPTJsSetting.useAI') === 'true') { logger('\u5df2\u5f00\u542fAI\u7b54\u9898\u529f\u80fd,\u51c6\u5907\u83b7\u53d6AI\u7b54\u6848...', '#1890ff'); // \u9898\u578b\u6620\u5c04 var typeMapping = { 0: '\u5355\u9009\u9898', 1: '\u5355\u9009\u9898', 2: '\u591a\u9009\u9898', 3: '\u586b\u7a7a\u9898', 4: '\u95ee\u7b54\u9898', 14: '\u5224\u65ad\u9898' }; var typeName = typeMapping[questionData.type] || '\u5355\u9009\u9898'; // \u8bbe\u7f6eAI\u7b54\u9898\u8d85\u65f6\u4fdd\u62a4 var aiTimeout = setTimeout(() => { logger('AI\u7b54\u9898\u7cfb\u7edf\u54cd\u5e94\u8d85\u65f6,\u8df3\u8fc7\u5f53\u524d\u9898\u76ee', 'red'); logger('⚠️ \u7b54\u6848\u9009\u62e9\u5931\u8d25,\u4e0d\u81ea\u52a8\u8df3\u9898,\u8bf7\u624b\u52a8\u5904\u7406', 'orange'); }, 30000); // 30\u79d2\u8d85\u65f6 // \u4e3aAI\u6784\u5efa\u5b8c\u6574\u7684\u9898\u76ee\u4fe1\u606f(\u9898\u578b+\u9898\u76ee+\u9009\u9879)- \u4fee\u590dAI\u6ca1\u6709\u6536\u5230\u9009\u9879\u4fe1\u606f\u7684\u95ee\u9898 let aiQuestionText = ''; if (typeName) { aiQuestionText += typeName + ': '; } aiQuestionText += questionData.question; // \u6dfb\u52a0\u9009\u9879\u4fe1\u606f if (questionData.options && questionData.options.length > 0) { aiQuestionText += '\n\u9009\u9879:\n'; questionData.options.forEach((option, index) => { const optionLabel = String.fromCharCode(65 + index); // A, B, C, D // \u4fee\u590d\u9009\u9879\u4fe1\u606f\u4f20\u9012\u95ee\u9898 - \u786e\u4fdd\u63d0\u53d6\u5b9e\u9645\u7684\u9009\u9879\u6587\u672c const optionText = option.content ? option.content.replace(/<[^>]*>/g, '').trim() : option.text ? option.text.trim() : (typeof option === 'string' ? option : String(option)); aiQuestionText += `${optionLabel}. ${optionText}\n`; }); } logger(`🤖 \u53d1\u9001\u7ed9AI\u7684\u5b8c\u6574\u9898\u76ee\u4fe1\u606f: ${aiQuestionText.substring(0, 200)}...`, 'blue'); zhsGetAIAnswer(aiQuestionText, typeName) .then(aiAnswer => { clearTimeout(aiTimeout); logger('AI\u6210\u529f\u56de\u7b54,\u7ee7\u7eed\u5904\u7406...', 'green'); selectZhihuishuOption(questionData, aiAnswer); }) .catch(error => { clearTimeout(aiTimeout); logger('AI\u56de\u7b54\u5931\u8d25: ' + error, 'red'); // AI\u5931\u8d25,\u8df3\u8fc7\u5f53\u524d\u9898\u76ee logger('⚠️ \u7b54\u6848\u9009\u62e9\u5931\u8d25,\u4e0d\u81ea\u52a8\u8df3\u9898,\u8bf7\u624b\u52a8\u5904\u7406', 'orange'); }); } else { // AI\u7b54\u9898\u529f\u80fd\u672a\u5f00\u542f,\u8df3\u8fc7\u5f53\u524d\u9898\u76ee logger('⚠️ AI\u7b54\u9898\u529f\u80fd\u672a\u5f00\u542f,\u7b54\u6848\u9009\u62e9\u5931\u8d25,\u4e0d\u81ea\u52a8\u8df3\u9898,\u8bf7\u624b\u52a8\u5904\u7406', 'orange'); } } // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664 - \u6839\u636e\u7528\u6237\u8981\u6c42\u5b8c\u5168\u5220\u9664\u968f\u673a\u9009\u62e9\u529f\u80fd // \u667a\u6167\u6811AI\u7b54\u9898\u51fd\u6570 - \u5b8c\u5168\u53c2\u8003xxt.js\u5b9e\u73b0 function zhsGetAIAnswer(question, typeName) { return new Promise((resolve, reject) => { if (!question || question.trim() === '') { reject('\u95ee\u9898\u4e0d\u80fd\u4e3a\u7a7a'); return; } // \u83b7\u53d6\u9009\u62e9\u7684\u6a21\u578b const model = localStorage.getItem('GPTJsSetting.model') || 'gpt-3.5-turbo-16k'; // \u83b7\u53d6\u7528\u6237\u914d\u7f6e\u7684 key let userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; // \u4e25\u683c\u68c0\u67e5key\u662f\u5426\u6709\u6548 if (!userKey || userKey.trim() === '' || userKey === '1') { reject('Key\u4e0d\u5b58\u5728\u6216\u65e0\u6548,\u8bf7\u524d\u5f80\u871c\u96ea\u6fc0\u6d3b'); return; } // \u5904\u7406\u9898\u76ee\u5185\u5bb9 let processedQuestion = question; // \u6839\u636e\u9898\u578b\u6784\u5efa\u63d0\u793a\u8bcd - \u4fee\u590dAI\u7b54\u9898\u7cfb\u7edf\u63d0\u793a\u8bcd\u95ee\u9898 let systemPrompt = "\u4f60\u662f\u4e00\u4e2a\u4e13\u4e1a\u7684\u7b54\u9898\u52a9\u624b。"; if (typeName) { systemPrompt += `\u8fd9\u662f\u4e00\u9053${typeName},\u8bf7\u7ed9\u51fa\u51c6\u786e\u7b54\u6848。`; // \u6839\u636e\u9898\u578b\u8c03\u6574\u63d0\u793a\u8bcd if (typeName.includes("\u5355\u9009\u9898")) { systemPrompt += "\u8bf7\u76f4\u63a5\u7ed9\u51fa\u6b63\u786e\u9009\u9879\u7684\u5b8c\u6574\u5185\u5bb9,\u4e0d\u8981\u8fd4\u56de\u9009\u9879\u5b57\u6bcd(\u5982A/B/C/D)。\u5982\u679c\u9898\u76ee\u5305\u542b\u9009\u9879,\u8bf7\u4ece\u7ed9\u51fa\u7684\u9009\u9879\u4e2d\u9009\u62e9\u6b63\u786e\u7b54\u6848。"; } else if (typeName.includes("\u591a\u9009\u9898")) { systemPrompt += "\u8bf7\u76f4\u63a5\u7ed9\u51fa\u6240\u6709\u6b63\u786e\u9009\u9879\u7684\u5b8c\u6574\u5185\u5bb9,\u7528###\u5206\u9694,\u4e0d\u8981\u8fd4\u56de\u9009\u9879\u5b57\u6bcd。\u5982\u679c\u9898\u76ee\u5305\u542b\u9009\u9879,\u8bf7\u4ece\u7ed9\u51fa\u7684\u9009\u9879\u4e2d\u9009\u62e9\u6b63\u786e\u7b54\u6848。"; } else if (typeName.includes("\u5224\u65ad\u9898")) { systemPrompt += "\u8bf7\u76f4\u63a5\u56de\u7b54'\u6b63\u786e'\u6216'\u9519\u8bef'。"; } else if (typeName.includes("\u586b\u7a7a\u9898")) { systemPrompt += "\u8bf7\u76f4\u63a5\u7ed9\u51fa\u586b\u7a7a\u5185\u5bb9,\u65e0\u9700\u989d\u5916\u8bf4\u660e。"; } } // \u6dfb\u52a0\u8c03\u8bd5\u4fe1\u606f // logger(`🤖 AI\u7b54\u9898\u8c03\u8bd5\u4fe1\u606f:`, 'blue'); // logger(` - \u9898\u578b: ${typeName}`, 'blue'); // logger(` - \u9898\u76ee\u957f\u5ea6: ${processedQuestion.length}`, 'blue'); // logger(` - SystemPrompt: ${systemPrompt}`, 'blue'); // \u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4 let requestTimedOut = false; const timeoutId = setTimeout(() => { requestTimedOut = true; reject('\u8bf7\u6c42\u8d85\u65f6,\u672a\u6536\u5230\u54cd\u5e94'); }, 130000); // 130\u79d2\u8d85\u65f6 try { // \u4f7f\u7528\u4e0exxt.js\u5b8c\u5168\u76f8\u540c\u7684API\u5730\u5740 const API_BASE_URL = (() => { const baseUrl = "tk.mixuelo.cc/api.php"; const protocol = window.location.protocol; if (protocol === 'https:') { return "https://" + baseUrl; } else { return "http://" + baseUrl; } })(); GM_xmlhttpRequest({ method: 'POST', url: API_BASE_URL + '?act=aimodel', headers: { 'Accept': 'application/json', 'Authorization': 'Bearer ' + userKey, 'Content-Type': 'application/x-www-form-urlencoded' }, data: `key=${encodeURIComponent(userKey)}&model=${encodeURIComponent(model)}&question=${encodeURIComponent(processedQuestion)}&system=${encodeURIComponent(systemPrompt)}`, timeout: 120000, // 120\u79d2\u8d85\u65f6 onload: function (response) { clearTimeout(timeoutId); if (requestTimedOut) return; try { if (!response.responseText) { resolve(""); return; } const result = JSON.parse(response.responseText); if (response.status === 200) { // \u68c0\u67e5\u662f\u5426\u6709\u9519\u8bef\u4fe1\u606f if (result.code === 1001) { resolve(""); return; } // \u5904\u7406\u6210\u529f\u54cd\u5e94 if (result.code === 1 && result.data) { resolve(result.data); } else { resolve(""); } } else { resolve(""); } } catch (e) { resolve(""); } }, onerror: function () { clearTimeout(timeoutId); if (requestTimedOut) return; resolve(""); }, ontimeout: function () { clearTimeout(timeoutId); resolve(""); } }); } catch (e) { clearTimeout(timeoutId); resolve(""); } }); } // \u968f\u673a\u7b54\u6848\u751f\u6210\u529f\u80fd\u5df2\u5220\u9664 - \u6839\u636e\u7528\u6237\u8981\u6c42\u5b8c\u5168\u5220\u9664\u968f\u673a\u9009\u62e9\u529f\u80fd // \u5904\u7406\u9898\u5e93API\u8fd4\u56de\u7684\u7b54\u6848 function zhsProcessAnswer(answer, questionType, optionList) { try { if (!optionList || optionList.length === 0) { logger('\u6ca1\u6709\u9009\u9879\u5217\u8868,\u65e0\u6cd5\u5904\u7406\u7b54\u6848', 'orange'); return; } // \u68c0\u67e5\u7b54\u6848\u662f\u5426\u6709\u6548 if (!answer || typeof answer !== 'string') { logger('\u7b54\u6848\u65e0\u6548,\u542f\u52a8\u5907\u7528\u65b9\u6848', 'orange'); logger('⚠️ \u7b54\u6848\u9009\u62e9\u5931\u8d25,\u4e0d\u81ea\u52a8\u8df3\u9898,\u8bf7\u624b\u52a8\u5904\u7406', 'orange'); return; } // \u6e05\u7406\u7b54\u6848\u6587\u672c var cleanAnswer = answer.replace(/<[^>]*>/g, '').trim(); logger(`\u5904\u7406\u7b54\u6848: ${cleanAnswer}`, 'blue'); // \u5904\u7406"###"\u5206\u9694\u7684\u591a\u4e2a\u7b54\u6848(\u7528\u6237\u793a\u4f8b\u683c\u5f0f) var answerParts = cleanAnswer.split('###').map(part => part.trim()).filter(part => part.length > 0); logger(`📝 \u7b54\u6848\u5206\u5272\u7ed3\u679c: ${JSON.stringify(answerParts)} (\u5171${answerParts.length}\u4e2a\u7b54\u6848)`, 'blue'); // \u67e5\u627e\u5339\u914d\u7684\u9009\u9879 var matchedOptions = []; optionList.forEach(function (option, index) { var optionText = option.content.replace(/<[^>]*>/g, '').trim(); var optionLabel = String.fromCharCode(65 + index); // A, B, C, D... // \u68c0\u67e5\u662f\u5426\u5339\u914d\u4efb\u4f55\u4e00\u4e2a\u7b54\u6848\u90e8\u5206 var isMatched = false; for (var i = 0; i < answerParts.length; i++) { var answerPart = answerParts[i]; // \u591a\u79cd\u5339\u914d\u65b9\u5f0f if (answerPart.includes(optionText) || optionText.includes(answerPart) || answerPart.includes(optionLabel) || answerPart === optionText) { isMatched = true; break; } } if (isMatched) { matchedOptions.push({ index: index, option: option, label: optionLabel }); logger(`✅ \u627e\u5230\u5339\u914d\u9009\u9879 ${optionLabel}: ${optionText}`, 'green'); } }); // \u6267\u884c\u9009\u62e9 if (matchedOptions.length > 0) { var successCount = 0; matchedOptions.forEach(function (match) { var success = zhsSelectOption(match.index, match.option); if (success) { successCount++; } }); if (successCount > 0) { logger(`🎯 \u6210\u529f\u9009\u62e9 ${successCount}/${matchedOptions.length} \u4e2a\u9009\u9879`, 'green'); logger(`📊 \u7b54\u9898\u7ed3\u679c: \u5df2\u9009\u62e9\u9009\u9879 ${matchedOptions.map(m => m.label).join(', ')}`, 'blue'); // \u66f4\u65b0\u9898\u76ee\u72b6\u6001\u6307\u793a\u5668\u4e3a\u6210\u529f\u72b6\u6001 const questionNumber = getCurrentQuestionNumber(); if (window.zhsQuestionLogger) { window.zhsQuestionLogger.logQuestion(questionNumber, 'success', { question: cleanAnswer, selectedOptions: matchedOptions.map(m => m.label).join(', '), status: '\u6210\u529f' }); } // \u53ea\u6709\u5728\u6210\u529f\u9009\u62e9\u9009\u9879\u540e\u624d\u81ea\u52a8\u8fdb\u884c\u4e0b\u4e00\u9898 setTimeout(() => { zhsContinueToNextQuestion(); }, 1500); } else { logger('❌ \u9009\u9879\u9009\u62e9\u5931\u8d25,\u4e0d\u81ea\u52a8\u8df3\u9898', 'red'); // \u66f4\u65b0\u9898\u76ee\u72b6\u6001\u6307\u793a\u5668\u4e3a\u5931\u8d25\u72b6\u6001 const questionNumber = getCurrentQuestionNumber(); if (window.zhsQuestionLogger) { window.zhsQuestionLogger.logQuestion(questionNumber, 'failed', { question: cleanAnswer, selectedOptions: '\u65e0', status: '\u5931\u8d25 - \u9009\u9879\u9009\u62e9\u5931\u8d25' }); } } } else { logger('❌ \u672a\u627e\u5230\u5339\u914d\u7684\u9009\u9879,\u542f\u52a8\u5907\u7528\u65b9\u6848', 'orange'); logger(`💡 \u63d0\u793a: \u7b54\u6848"${cleanAnswer}"\u4e0e\u9009\u9879\u4e0d\u5339\u914d`, 'blue'); // \u66f4\u65b0\u9898\u76ee\u72b6\u6001\u6307\u793a\u5668\u4e3a\u5931\u8d25\u72b6\u6001 const questionNumber = getCurrentQuestionNumber(); if (window.zhsQuestionLogger) { window.zhsQuestionLogger.logQuestion(questionNumber, 'failed', { question: cleanAnswer, selectedOptions: '\u65e0', status: '\u5931\u8d25 - \u672a\u627e\u5230\u5339\u914d\u9009\u9879' }); } // \u968f\u673a\u9009\u62e9\u529f\u80fd\u5df2\u5220\u9664,\u8df3\u8fc7\u5f53\u524d\u9898\u76ee logger('⚠️ \u7b54\u6848\u9009\u62e9\u5931\u8d25,\u4e0d\u81ea\u52a8\u8df3\u9898,\u8bf7\u624b\u52a8\u5904\u7406', 'orange'); } } catch (e) { logger(`\u5904\u7406\u7b54\u6848\u65f6\u51fa\u9519: ${e.message}`, 'red'); // \u968f\u673a\u9009\u62e9\u529f\u80fd\u5df2\u5220\u9664,\u8df3\u8fc7\u5f53\u524d\u9898\u76ee logger('⚠️ \u7b54\u6848\u9009\u62e9\u5931\u8d25,\u4e0d\u81ea\u52a8\u8df3\u9898,\u8bf7\u624b\u52a8\u5904\u7406', 'orange'); } } // \u9009\u62e9\u6307\u5b9a\u9009\u9879 - \u57fa\u4e8exxt.js\u7684\u6210\u529f\u7ecf\u9a8c,\u8fd4\u56de\u662f\u5426\u6210\u529f function zhsSelectOption(index, option, autoNext = false) { try { logger(`\u5c1d\u8bd5\u9009\u62e9\u9009\u9879 ${String.fromCharCode(65 + index)}: ${option.content ? option.content.replace(/<[^>]*>/g, '').trim() : option}`, 'blue'); // \u591a\u79cd\u9009\u62e9\u5668\u5c1d\u8bd5,\u57fa\u4e8e\u667a\u6167\u6811\u5e73\u53f0\u7684\u5b9e\u9645\u7ed3\u6784 var selectors = [ '.TitleOptions-div input', '.optionUl input', '.el-radio input', '.el-checkbox input', 'input[type="radio"]', 'input[type="checkbox"]', '.option-item input', '.question-option input' ]; var $input = null; var $container = null; // \u5c1d\u8bd5\u627e\u5230\u5bf9\u5e94\u7684\u8f93\u5165\u5143\u7d20 for (var i = 0; i < selectors.length; i++) { var elements = document.querySelectorAll(selectors[i]); if (elements && elements[index]) { $input = elements[index]; $container = $input.closest('.TitleOptions-div, .optionUl, .el-radio, .el-checkbox, .option-item, .question-option'); logger(`\u4f7f\u7528\u9009\u62e9\u5668 ${selectors[i]} \u627e\u5230\u9009\u9879`, 'green'); break; } } if ($input) { // \u57fa\u4e8exxt.js\u7684\u591a\u79cd\u70b9\u51fb\u65b9\u5f0f var clickSuccess = false; try { // \u65b9\u6cd51: \u76f4\u63a5\u70b9\u51fb\u8f93\u5165\u5143\u7d20 $input.click(); $input.checked = true; logger(`\u6210\u529f\u70b9\u51fb\u9009\u9879 ${String.fromCharCode(65 + index)}`, 'green'); clickSuccess = true; } catch (e) { logger(`\u76f4\u63a5\u70b9\u51fb\u5931\u8d25: ${e.message}`, 'orange'); } if (!clickSuccess && $container) { try { // \u65b9\u6cd52: \u70b9\u51fb\u5bb9\u5668\u5143\u7d20 $container.click(); logger(`\u70b9\u51fb\u5bb9\u5668\u6210\u529f\u9009\u62e9\u9009\u9879 ${String.fromCharCode(65 + index)}`, 'green'); clickSuccess = true; } catch (e) { logger(`\u70b9\u51fb\u5bb9\u5668\u5931\u8d25: ${e.message}`, 'orange'); } } if (!clickSuccess && $) { try { // \u65b9\u6cd53: \u4f7f\u7528jQuery $($input).prop('checked', true).trigger('click').trigger('change'); if ($container) { $($container).trigger('click'); } logger(`\u4f7f\u7528jQuery\u9009\u62e9\u9009\u9879 ${String.fromCharCode(65 + index)}`, 'green'); clickSuccess = true; } catch (e) { logger(`jQuery\u70b9\u51fb\u5931\u8d25: ${e.message}`, 'orange'); } } if (!clickSuccess) { try { // \u65b9\u6cd54: \u4e8b\u4ef6\u6a21\u62df var clickEvent = new MouseEvent('click', { bubbles: true, cancelable: true, view: window }); $input.dispatchEvent(clickEvent); var changeEvent = new Event('change', { bubbles: true }); $input.dispatchEvent(changeEvent); logger(`\u4f7f\u7528\u4e8b\u4ef6\u6a21\u62df\u9009\u62e9\u9009\u9879 ${String.fromCharCode(65 + index)}`, 'green'); clickSuccess = true; } catch (e) { logger(`\u4e8b\u4ef6\u6a21\u62df\u5931\u8d25: ${e.message}`, 'red'); } } // \u6dfb\u52a0\u5230\u961f\u5217 if (setting.queue) { setting.queue.push($input); } // \u53ea\u6709\u5728autoNext\u4e3atrue\u65f6\u624d\u81ea\u52a8\u8df3\u8f6c if (autoNext && clickSuccess) { setTimeout(() => { zhsContinueToNextQuestion(); }, 1500); } return clickSuccess; } else { logger(`\u672a\u627e\u5230\u9009\u9879 ${String.fromCharCode(65 + index)} \u7684\u8f93\u5165\u5143\u7d20`, 'orange'); return false; } } catch (e) { logger(`\u9009\u62e9\u9009\u9879\u65f6\u51fa\u9519: ${e.message}`, 'red'); return false; } } // \u7ee7\u7eed\u4e0b\u4e00\u9898 - \u4fee\u590d\u81ea\u52a8\u4e0b\u4e00\u9898\u529f\u80fd function zhsContinueToNextQuestion() { try { // \u9996\u5148\u68c0\u67e5\u7b54\u9898\u72b6\u6001 - \u53ea\u6709\u5728\u7b54\u9898\u5f00\u542f\u65f6\u624d\u81ea\u52a8\u5bfc\u822a const isAutoAnswerEnabled = localStorage.getItem('GPTJsSetting.work') === 'true'; if (!isAutoAnswerEnabled) { logger(`🛑 \u81ea\u52a8\u7b54\u9898\u5df2\u5173\u95ed,\u505c\u6b62\u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898`, 'orange'); return false; } // \u4e25\u683c\u68c0\u67e5API Key - \u5fc5\u987b\u914d\u7f6e\u6709\u6548key\u624d\u80fd\u81ea\u52a8\u5bfc\u822a const userKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; if (!userKey || userKey.trim() === '' || userKey === '1') { logger(`🛑 \u672a\u914d\u7f6e\u6709\u6548Key,\u505c\u6b62\u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898`, 'orange'); return false; } logger('🔄 \u51c6\u5907\u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898', 'blue'); // \u76f4\u63a5\u67e5\u627e\u5e76\u70b9\u51fb\u4e0b\u4e00\u9898\u6309\u94ae setTimeout(() => { const nextBtn = document.querySelector('.Topicswitchingbtn'); if (nextBtn && nextBtn.textContent.includes('\u4e0b\u4e00\u9898')) { nextBtn.click(); logger('🔄 \u81ea\u52a8\u5bfc\u822a\u5230\u4e0b\u4e00\u9898\u6210\u529f', 'green'); // \u5ef6\u8fdf\u540e\u91cd\u65b0\u542f\u52a8\u7b54\u9898\u5904\u7406 setTimeout(() => { if (checkZhsAnswerPage()) { zhsProcessQuestions(); } }, 2000); } else { logger('❌ \u672a\u627e\u5230\u4e0b\u4e00\u9898\u6309\u94ae,\u53ef\u80fd\u5df2\u5b8c\u6210\u6240\u6709\u9898\u76ee', 'orange'); } }, 1000); return true; } catch (e) { logger(`\u7ee7\u7eed\u4e0b\u4e00\u9898\u65f6\u51fa\u9519: ${e.message}`, 'red'); } } // \u968f\u673a\u9009\u62e9\u529f\u80fd\u5df2\u5220\u9664 - \u6839\u636e\u7528\u6237\u8981\u6c42\u5b8c\u5168\u5220\u9664\u968f\u673a\u9009\u62e9\u529f\u80fd // \u521b\u5efa\u6d6e\u52a8\u6309\u94ae function createZhsFloatingButton() { // \u9632\u6b62\u91cd\u590d\u521b\u5efa if (document.getElementById('zhs-floating-button')) return; const currentKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const isConfigured = !!currentKey; const button = document.createElement('div'); button.id = 'zhs-floating-button'; button.className = 'zhs-floating-button'; button.innerHTML = '⚙️'; button.title = isConfigured ? 'API Key\u5df2\u914d\u7f6e - \u70b9\u51fb\u6253\u5f00\u8bbe\u7f6e' : '\u8bf7\u914d\u7f6eAPI Key - \u70b9\u51fb\u6253\u5f00\u8bbe\u7f6e'; // \u6dfb\u52a0\u72b6\u6001\u6307\u793a\u5668 const indicator = document.createElement('div'); indicator.className = `zhs-status-indicator ${isConfigured ? 'configured' : 'not-configured'}`; indicator.innerHTML = isConfigured ? '✓' : '!'; button.appendChild(indicator); // \u70b9\u51fb\u4e8b\u4ef6 button.addEventListener('click', function () { const panel = document.getElementById('zhs-config-panel'); if (panel) { panel.remove(); } else { createZhsConfigPanel(); } }); document.body.appendChild(button); } // \u66f4\u65b0\u6d6e\u52a8\u6309\u94ae\u72b6\u6001 function updateZhsFloatingButton() { const button = document.getElementById('zhs-floating-button'); const indicator = button ? button.querySelector('.zhs-status-indicator') : null; if (button && indicator) { const currentKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; const isConfigured = !!currentKey; button.title = isConfigured ? 'API Key\u5df2\u914d\u7f6e - \u70b9\u51fb\u6253\u5f00\u8bbe\u7f6e' : '\u8bf7\u914d\u7f6eAPI Key - \u70b9\u51fb\u6253\u5f00\u8bbe\u7f6e'; indicator.className = `zhs-status-indicator ${isConfigured ? 'configured' : 'not-configured'}`; indicator.innerHTML = isConfigured ? '✓' : '!'; } } // \u521d\u59cb\u5316\u667a\u6167\u6811\u914d\u7f6e\u7cfb\u7edf function initZhsConfigSystem() { // \u5f3a\u5236\u91cd\u65b0\u521d\u59cb\u5316 - \u786e\u4fdd\u65b0\u914d\u7f6e\u751f\u6548 window.zhsConfigInitialized = true; logger('\u521d\u59cb\u5316\u667a\u6167\u6811\u914d\u7f6e\u7cfb\u7edf', 'blue'); // \u68c0\u67e5API Key\u914d\u7f6e\u72b6\u6001 const currentKey = localStorage.getItem('GPTJsSetting.key') || localStorage.getItem('tiku_key') || ''; if (currentKey) { logger('\u68c0\u6d4b\u5230\u5df2\u914d\u7f6e\u7684API Key: ' + currentKey.substring(0, 8) + '...', 'green'); } else { logger('\u672a\u68c0\u6d4b\u5230API Key\u914d\u7f6e,\u8bf7\u914d\u7f6e\u540e\u4f7f\u7528', 'orange'); } // \u521d\u59cb\u5316\u7b54\u9898\u914d\u7f6e\u7cfb\u7edf - \u4fee\u6539\u9ed8\u8ba4\u914d\u7f6e:\u4e0d\u5f00\u542f\u9898\u5e93\u7b54\u9898,\u9ed8\u8ba4GPT-3.5-Turbo\u6a21\u578b // \u53ea\u5728\u9996\u6b21\u521d\u59cb\u5316\u65f6\u8bbe\u7f6e\u9ed8\u8ba4\u503c,\u4fdd\u6301\u7528\u6237\u7684\u914d\u7f6e\u9009\u62e9 const settingDefaults = { 'GPTJsSetting.useTiku': 'false', // \u9898\u5e93\u7b54\u9898\u9ed8\u8ba4\u5173\u95ed 'GPTJsSetting.useAI': 'false', // AI\u7b54\u9898\u9ed8\u8ba4\u5173\u95ed,\u53ea\u6709\u6709\u6548key\u65f6\u624d\u5f00\u542f // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664 // \u5907\u7528\u9898\u5e93\u529f\u80fd\u5df2\u5220\u9664 'GPTJsSetting.autoSubmit': 'false', // \u81ea\u52a8\u63d0\u4ea4\u9ed8\u8ba4\u5173\u95ed 'GPTJsSetting.showAnswer': 'true', // \u663e\u793a\u7b54\u6848\u9ed8\u8ba4\u5f00\u542f 'GPTJsSetting.model': 'gpt-3.5-turbo-16k' // \u9ed8\u8ba4GPT-3.5-Turbo\u6a21\u578b }; // \u53ea\u5728\u914d\u7f6e\u4e0d\u5b58\u5728\u65f6\u8bbe\u7f6e\u9ed8\u8ba4\u503c,\u4fdd\u6301\u7528\u6237\u914d\u7f6e Object.keys(settingDefaults).forEach(key => { if (localStorage.getItem(key) === null) { localStorage.setItem(key, settingDefaults[key]); } }); // \u53ea\u6709\u5728\u6709\u6709\u6548key\u65f6\u624d\u542f\u7528AI\u7b54\u9898\u529f\u80fd - \u4fee\u590d\u65e0key\u4e5f\u80fd\u7b54\u9898\u7684\u95ee\u9898 if (currentKey && currentKey.trim() !== '' && currentKey !== '1') { // \u6709\u6709\u6548key\u65f6,\u786e\u4fddAI\u7b54\u9898\u529f\u80fd\u5f00\u542f if (localStorage.getItem('GPTJsSetting.useAI') !== 'true') { logger('\u68c0\u6d4b\u5230\u6709\u6548Key,\u542f\u7528AI\u7b54\u9898\u529f\u80fd', 'green'); localStorage.setItem('GPTJsSetting.useAI', 'true'); } } else { // \u6ca1\u6709\u6709\u6548key\u65f6,\u5173\u95edAI\u7b54\u9898\u529f\u80fd if (localStorage.getItem('GPTJsSetting.useAI') === 'true') { logger('\u68c0\u6d4b\u5230\u65e0\u6548Key,\u5173\u95edAI\u7b54\u9898\u529f\u80fd', 'orange'); localStorage.setItem('GPTJsSetting.useAI', 'false'); } } // \u5220\u9664\u5f3a\u5236\u542f\u7528\u9898\u5e93API\u7684\u903b\u8f91,\u5c0a\u91cd\u7528\u6237\u914d\u7f6e // \u6ce8\u91ca\u6389\u539f\u6765\u7684\u5f3a\u5236\u542f\u7528\u903b\u8f91 // if (localStorage.getItem('GPTJsSetting.useTiku') !== 'true') { // logger('\u68c0\u6d4b\u5230\u9898\u5e93API\u88ab\u7981\u7528,\u5f3a\u5236\u542f\u7528\u9898\u5e93API', 'orange'); // localStorage.setItem('GPTJsSetting.useTiku', 'true'); // } // \u9ed8\u8ba4\u4e0d\u5f00\u542f\u81ea\u52a8\u7b54\u9898\u529f\u80fd - \u9700\u8981\u624b\u52a8\u5f00\u542f if (localStorage.getItem('GPTJsSetting.work') === null) { localStorage.setItem('GPTJsSetting.work', 'false'); } if (localStorage.getItem('ZhsJsSetting.work') === null) { localStorage.setItem('ZhsJsSetting.work', 'false'); } setting.work = localStorage.getItem('GPTJsSetting.work') === 'true'; logger('\ud83d\udccb \u81ea\u52a8\u7b54\u9898\u529f\u80fd\u72b6\u6001: ' + (setting.work ? '\u5f00\u542f' : '\u5173\u95ed\uff08\u9700\u624b\u52a8\u5f00\u542f\uff09'), setting.work ? 'green' : 'orange'); // \u4e0d\u518d\u81ea\u52a8\u542f\u52a8\u7b54\u9898\u6d41\u7a0b\uff0c\u9700\u8981\u624b\u52a8\u5f00\u542f // setTimeout(() => { // if (checkZhsAnswerPage()) { // logger('\ud83c\udfaf \u68c0\u6d4b\u5230\u7b54\u9898\u9875\u9762\uff0c\u7acb\u5373\u542f\u52a8\u81ea\u52a8\u7b54\u9898', 'green'); // zhsProcessQuestions(); // } // }, 2000); // \u521d\u59cb\u5316\u8bbe\u7f6e\u9879\u7684UI\u72b6\u6001 setTimeout(() => { Object.keys(settingDefaults).forEach(key => { const element = document.getElementById(key); if (element) { if (element.type === 'checkbox') { element.checked = localStorage.getItem(key) === 'true'; element.addEventListener('change', () => { localStorage.setItem(key, element.checked.toString()); }); } else if (element.tagName === 'SELECT') { element.value = localStorage.getItem(key) || settingDefaults[key]; element.addEventListener('change', () => { localStorage.setItem(key, element.value); }); } } }); // \u7279\u522b\u5904\u7406AI\u52a9\u624b\u9762\u677f\u7684\u6a21\u578b\u9009\u62e9 const aiModelSelect = document.getElementById('zhs-ai-model'); if (aiModelSelect) { const savedModel = localStorage.getItem('GPTJsSetting.model') || 'DeepSeek-Chat'; aiModelSelect.value = savedModel; aiModelSelect.addEventListener('change', (e) => { const selectedModel = e.target.value; localStorage.setItem('GPTJsSetting.model', selectedModel); logger(`AI\u6a21\u578b\u5df2\u5207\u6362\u4e3a: ${selectedModel}`, 'blue'); }); logger(`AI\u52a9\u624b\u6a21\u578b\u9009\u62e9\u5df2\u521d\u59cb\u5316: ${savedModel}`, 'green'); } }, 1000); // \u79fb\u9664\u91cd\u590d\u7684\u914d\u7f6e\u8bbe\u7f6e\uff0c\u907f\u514d\u8986\u76d6\u7528\u6237\u914d\u7f6e // \u6240\u6709\u9ed8\u8ba4\u914d\u7f6e\u5df2\u5728\u4e0a\u9762\u7684settingDefaults\u4e2d\u7edf\u4e00\u5904\u7406 logger('\u914d\u7f6e\u521d\u59cb\u5316\u5b8c\u6210\uff0c\u7b54\u9898\u529f\u80fd\u72b6\u6001: ' + (setting.work ? '\u5f00\u542f' : '\u5173\u95ed'), 'green'); // \u663e\u793a\u7b54\u9898\u4f18\u5148\u7ea7\u914d\u7f6e\u72b6\u6001 - \u5b9e\u65f6\u68c0\u67e5 const workStatus = localStorage.getItem('GPTJsSetting.work') === 'true'; const useAI = localStorage.getItem('GPTJsSetting.useAI') === 'true'; const useTiku = localStorage.getItem('GPTJsSetting.useTiku') === 'true'; // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664 logger('\u2705 \u5b8c\u6574\u914d\u7f6e\u72b6\u6001\u68c0\u67e5:', 'blue'); logger(' - \u81ea\u52a8\u7b54\u9898\u529f\u80fd: ' + workStatus, workStatus ? 'green' : 'red'); logger(' - \u9898\u5e93API: ' + useTiku, useTiku ? 'green' : 'red'); logger(' - AI\u7b54\u9898: ' + useAI, useAI ? 'green' : 'red'); // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664 // \u968f\u673a\u7b54\u9898\u529f\u80fd\u5df2\u5220\u9664\uff0csetting.none\u8bbe\u4e3a0 setting.none = 0; // \u4e0d\u518d\u81ea\u52a8\u542f\u52a8\u9898\u76ee\u5904\u7406\uff0c\u9700\u8981\u624b\u52a8\u5f00\u542f\u7b54\u9898 setTimeout(() => { const isAnswerPage = checkZhsAnswerPage(); if (isAnswerPage) { logger('\u68c0\u6d4b\u5230\u667a\u6167\u6811\u7b54\u9898\u9875\u9762\uff0c\u7b49\u5f85\u624b\u52a8\u5f00\u542f\u7b54\u9898', 'blue'); logger('\ud83d\udca1 \u8bf7\u70b9\u51fb\u63a7\u5236\u9762\u677f\u4e2d\u7684\u201c\u5f00\u59cb\u7b54\u9898\u201d\u6309\u94ae\u5f00\u59cb\u81ea\u52a8\u7b54\u9898', 'orange'); } }, 2000); // \u65e7\u7684\u6d6e\u52a8\u6309\u94ae\u548c\u914d\u7f6e\u9762\u677f\u5df2\u88ab\u65b0\u7684\u63a7\u5236\u9762\u677f\u66ff\u4ee3 // setTimeout(() => { // createZhsFloatingButton(); // }, 1000); // F9\u5feb\u6377\u952e\u73b0\u5728\u7531\u65b0\u7684\u63a7\u5236\u9762\u677f\u7cfb\u7edf\u5904\u7406 // document.addEventListener('keydown', function (e) { // if (e.key === 'F9') { // e.preventDefault(); // const panel = document.getElementById('zhs-config-panel'); // if (panel) { // panel.remove(); // } else { // createZhsConfigPanel(); // } // } // }); // \u5982\u679c\u6ca1\u6709\u914d\u7f6eAPI Key\uff0c\u663e\u793a\u5f3a\u70c8\u63d0\u793a if (!currentKey) { setTimeout(() => { logger('\ud83d\udca1 \u63d0\u793a\uff1a\u6309F9\u6216\u70b9\u51fb\u53f3\u4e0b\u89d2\u8bbe\u7f6e\u6309\u94ae\u914d\u7f6eAPI Key', 'blue'); // \u663e\u793a\u66f4\u660e\u663e\u7684\u914d\u7f6e\u63d0\u793a setTimeout(() => { logger('\u26a0\ufe0f \u91cd\u8981\uff1a\u5f53\u524d\u672a\u914d\u7f6eAPI Key\uff0c\u65e0\u6cd5\u8fdb\u884c\u81ea\u52a8\u7b54\u9898\uff01', 'red'); logger('\ud83d\udd27 \u914d\u7f6e\u65b9\u6cd5\uff1a\u6309F9\u952e\u6253\u5f00\u914d\u7f6e\u9762\u677f\uff0c\u8f93\u5165API Key', 'orange'); // \u914d\u7f6e\u63d0\u793a\u73b0\u5728\u901a\u8fc7\u65b0\u7684\u63a7\u5236\u9762\u677f\u5904\u7406 setTimeout(() => { const stillNoKey = !localStorage.getItem('GPTJsSetting.key') && !localStorage.getItem('tiku_key'); if (stillNoKey) { logger('\ud83d\udea8 \u8bf7\u4f7f\u7528\u65b0\u7684\u63a7\u5236\u9762\u677f\u914d\u7f6eAPI Key\u4ee5\u83b7\u53d6\u6b63\u786e\u7b54\u6848', 'red'); logger('\ud83d\udca1 \u6309F9\u952e\u6253\u5f00\u63a7\u5236\u9762\u677f\u8fdb\u884c\u914d\u7f6e', 'blue'); // createZhsConfigPanel(); // \u5df2\u88ab\u65b0\u63a7\u5236\u9762\u677f\u66ff\u4ee3 } }, 5000); }, 3000); }, 2000); } } // \u5168\u5c40\u51fd\u6570\u5df2\u5728\u51fd\u6570\u5b9a\u4e49\u540e\u7acb\u5373\u58f0\u660e,\u907f\u514d\u91cd\u590d\u58f0\u660e