版本比较
网站字体更换器
正文
增加 762 行删除 409 行
1123455678789101112680 行未改动全部展开69369469569669769869970070170270370470570670770870971071171271371471571671771871969769869970070170270372772870470570670729 行未改动73773873974076676776876977077177277377474174274374474574674774874975075175277675375475575675775875976076176278376376476576676776878976977077177277379477477577677777877978078180280380480578278378478530 行未改动816817818819844820821822846823824825848849850826827828829830831832833834153 行未改动全部展开98898999099199299310139949951015101610171018996997998999100010011002100310221004100510061007100816 行未改动1025102610271028102910301031103210331034103510361052103710381039104010411042104310441045104610471048105410491050105110521053105410551056105727 行未改动10851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121100111311141115111611171118111911201121122 行未改动全部展开1244124512461247124812491250125112521253125412551256341 行未改动全部展开159815991600160115821602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122821,650 行未改动全部展开39333934393539363243393739383939394039413 行未改动3945394639473948394939503951395239533954395532563956395739583959396039613962396339643266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611配置异常简单,下载油猴插件,谷歌浏览器开fq或者下载[安装包](https://pan.quark.cn/s/1ac7209c3f94#/list/share)\配置:下载油猴插件,谷歌浏览器开fq或者下载[安装包](https://pan.quark.cn/s/1ac7209c3f94#/list/share)\点击油猴-->添加新脚本->ctrl+a再ctrl+v然后ctrl+s就行了```js// ==UserScript==// @name BZOJ 增强工具 + 网页字体更换器// @name Hydro OJ 增强工具 + 网页字体更换器// @namespace https://bzoj.org/// @version 2.0.1// @description 整合 BZOJ 测试点大方块(自动轮询、完成通知、亮暗模式适配、总分数垂直对齐)、全站网页字体更换器、以及题目 Markdown 块内查看/复制功能(右上角按钮,可撤销),BZOJ 功能仅在 bzoj.org 下激活// @version 2.5.3// @description 整合 Hydro OJ 测试点大方块(自动轮询、完成通知、亮暗模式适配、总分数垂直对齐,兼容所有 Hydro 系 OJ)、全站网页字体更换器、题目 Markdown 块内查看/复制功能(右上角按钮,可撤销,兼容所有 Hydro 系 OJ,支持在线编程模式)、题目列表「提交」快捷列(仅在题库/比赛/作业/训练列表页显示)、以及比赛/作业成绩表增强(黄色高亮当前用户 + 详细状态方块)// @author bzoj-enhancer & FontSwitcher// @match *://*/*// @grant GM_notification// @grant GM_addStyle680 行未改动全部展开 } }, 2000); },
/** * 手动偏移状态栏:从 GM_getValue 读取用户设置的偏移量(px), * 用 transform: translateY() 应用到状态栏 h1 内所有子元素 * (图标、分数、状态文本),让整体一起上下移动。 * 默认 -6px(用户实测的舒适值)。 */ _applyScoreOffset: function () { const title = document.querySelector('#status .section__title, .section[data-status] .section__title'); if (!title) return;
// 读取偏移量(px),默认 -6,正数=下移,负数=上移 const offset = parseFloat(GM_getValue('bzoj_score_offset', '-6')) || 0; const transform = offset !== 0 ? `translateY(${offset}px)` : '';
// 应用到 h1 内所有子元素(图标、分数、状态文本) const children = Array.from(title.children); for (const c of children) { c.style.transform = transform; c.style.display = 'inline-block'; c.style.verticalAlign = 'middle'; } },
installObserver: function () { const self = this; if (this.observer) return;
this.observer = new MutationObserver(() => { // 立即隐藏表格(不防抖,避免闪烁) self._hideTables(); // 重新应用分数偏移(Hydro 重建 DOM 时 transform 会丢失) self._applyScoreOffset();
// 重建方块需要防抖,等 DOM 稳定后再处理 clearTimeout(self._observerDebounce); self._observerDebounce = setTimeout(() => {29 行未改动 .bzoj-hide-table { display: none !important; } .bzoj-hide-container { display: none !important; } .bzoj-hide-section-body { display: none !important; }
/* ============ 修复 record 页面总分数垂直居中 ============ */ /* Hydro 的 record 状态栏结构: <h1 class="section__title"> <span class="icon record-status--icon pass"></span> // 图标(background-image,固定尺寸) <span style="color: #25ad40">100</span> // 分数(无 class,inline style) <span class="record-status--text pass">Accepted</span> // 状态文本 </h1> 问题:分数 span 的字体高度与图标/状态文本不一致,导致垂直中心偏低。 策略:用 flex 居中 + JS 运行时测量精确修正。 */ /* ============ 修复 record 状态栏框太扁的问题 ============ */ /* Hydro 的 record 状态栏 <h1 class="section__title"> 内有图标、分数、状态文本, 默认 section__header 的 padding 不足,导致框太扁、内容显得没居中。 策略:增加 section__header 的上下 padding,让框变高,内容自然垂直居中。 */
/* 1. 增加 section__header 的上下 padding,让框变高 */ #status > .section__header, .section[data-status] > .section__header { padding-top: 14px !important; padding-bottom: 14px !important; }
/* 1. 让状态栏 h1 使用 flex 居中 */ /* 2. 让状态栏 h1 使用 flex 居中 */ #status .section__title, .section[data-status] > .section__header > .section__title { display: flex !important; align-items: center !important; gap: 8px !important; line-height: 1.4 !important; margin: 0 !important; }
/* 2. 所有子元素统一为 inline-block + 垂直居中 */ /* 3. 所有子元素统一为 inline-block + 垂直居中 */ #status .section__title > *, .section[data-status] > .section__header > .section__title > * { display: inline-block !important; vertical-align: middle !important; align-self: center !important; line-height: 1.2 !important; line-height: 1.4 !important; margin-top: 0 !important; margin-bottom: 0 !important; }
/* 3. 图标保留 Hydro 原有尺寸 */ /* 4. 图标保留 Hydro 原有尺寸 */ #status .section__title .record-status--icon, .section[data-status] .section__title .record-status--icon { flex-shrink: 0 !important; line-height: 1 !important; } `);
// 4. 应用用户设置的分数偏移(默认 -6px) self._applyScoreOffset(); // MutationObserver 会在 DOM 变化时重新调用
const initialResult = self.extractTestCases(document); if (initialResult) { self._lastResult = initialResult; const allDone = self.updateBlocks(initialResult);30 行未改动 _modal: null, _lastMarkdown: '',
init: function () { // 1. 路径检测:必须是 /p/<id>,排除 /p/<id>/submit、/p/<id>/solution 等子路径 // 自动检测 Hydro OJ 题目详情页(兼容 bzoj.org / hydro.ac 及所有 Hydro 系 OJ) // 1. 路径匹配:/p/[id] 或 /d/[domain]/p/[id](排除 /p/[id]/submit、/p/[id]/solution 等子路径) const path = window.location.pathname; if (!/^\/p\/[^\/]+$/.test(path)) return; const match = path.match(/\/p\/([^\/]+)$/); if (!match) return;
// 2. 结构检测:必须存在题面正文容器 const content = document.querySelector('.problem-content, [data-fragment-id="problem-description"]'); if (!content) return; // 2. 结构检测:页面是否有 Hydro 题目特征元素 const hasHydroElements = document.querySelector('.problem-content') || document.querySelector('[data-fragment-id="problem-description"]') || document.querySelector('.problem-content-container'); if (!hasHydroElements) return;
// 3. 排除 iframe 等嵌套文档 if (window.top !== window.self) return;
153 行未改动全部展开 background: #56758f; color: #fff; border-color: #56758f; }
/* ============ 块内 MD 源码视图(替换题面 HTML) ============ */ /* 透明背景 + 继承字号,直接融入题目块容器,不出现单独的「灰色框」 */ .bzoj-md-inline-view { padding: 16px 20px; margin: 0; padding: 0; margin: 0; font-family: "JetBrains Mono", "Cascadia Code", Consolas, "Source Code Pro", "Microsoft YaHei", monospace; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; background: rgba(86,117,143,0.03); border-radius: 6px; color: #333; font-size: inherit; line-height: inherit; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; background: transparent; border: none; border-radius: 0; color: inherit; overflow: visible; } .theme--dark .bzoj-md-inline-view, html[data-mantine-color-scheme="dark"] .bzoj-md-inline-view { background: rgba(255,255,255,0.04); color: #ddd; background: transparent; color: inherit; } .bzoj-md-restored-banner { display: flex; align-items: center; gap: 8px; padding: 8px 14px; margin-bottom: 10px;16 行未改动 self.addSidebarButton(menu); } else { self.addFloatingButton(); }
// 监听 DOM 变化:用户进入/退出在线编程模式(scratchpad)时重新注入按钮 self._installModeObserver(); },
/** 在题目块右上角注入两个浮动按钮:「显示 MD」「复制 MD」 */ addActionButtons: function () { const self = this; if (document.querySelector('.bzoj-md-actions')) return; // 防止重复注入 // 移除已存在但已失效的按钮(如 scratchpad 模式切换导致旧按钮在隐藏容器中) const existing = document.querySelector('.bzoj-md-actions'); if (existing) { const parent = existing.parentElement; if (parent) { const cs = getComputedStyle(parent); const invisible = cs.display === 'none' || parseFloat(cs.opacity) < 0.1; if (invisible) existing.remove(); else return; // 已有可见按钮,不重复注入 } }
// 定位题目内容容器,按钮组将绝对定位在其右上角 // 定位题目内容容器:优先 scratchpad 模式下的可见 .problem-content, // 其次普通模式的 .problem-content-container const scratchpadContent = document.querySelector('.scratchpad__problem .problem-content, .scratchpad__problem [data-fragment-id="problem-description"]'); const anchor = scratchpadContent || document.querySelector('.problem-content-container') || (document.querySelector('.problem-content')?.closest('.section')) || document.querySelector('.problem-content'); if (!anchor) return;27 行未改动
anchor.appendChild(actions); },
/** 安装模式切换监听器:scratchpad 模式切换时重新注入按钮 */ _installModeObserver: function () { const self = this; if (self._mdObserver) return;
self._mdObserver = new MutationObserver(function () { clearTimeout(self._mdObserverDebounce); self._mdObserverDebounce = setTimeout(function () { self.addActionButtons(); }, 200); }); self._mdObserver.observe(document.body, { attributes: true, attributeFilter: ['class'] }); self._mdObserver.observe(document.body, { childList: true, subtree: true }); },
/** * 在题面块内切换 Markdown 源码视图(可撤销)。 * - 首次点击:保存原始 HTML,将题面正文替换为 <pre class="bzoj-md-inline-view"> 显示 MD 源码 * - 再次点击:恢复原始 HTML */ _inlineMdState: null, // { originalHtml, viewEl, anchor } toggleInlineMd: function (btn) { const self = this;
// 定位题面正文容器(与 getProblemMarkdown 一致) // 定位题面正文容器(优先 scratchpad 模式下的可见题面) const fragment = document.querySelector('.scratchpad__problem [data-fragment-id="problem-description"]') || document.querySelector('.scratchpad__problem .problem-content .section__body') || document.querySelector('.scratchpad__problem .problem-content') || document.querySelector('[data-fragment-id="problem-description"]') || document.querySelector('.problem-content .section__body') || document.querySelector('.problem-content'); if (!fragment) {122 行未改动全部展开 },
/** 提取题面 HTML 并转换为 Markdown */ getProblemMarkdown: function () { // 优先 scratchpad 模式下的可见题面,其次普通模式 const fragment = document.querySelector('.scratchpad__problem [data-fragment-id="problem-description"]') || document.querySelector('.scratchpad__problem .problem-content .section__body') || document.querySelector('.scratchpad__problem .problem-content') || document.querySelector('[data-fragment-id="problem-description"]') || document.querySelector('.problem-content .section__body') || document.querySelector('.problem-content'); if (!fragment) return '';341 行未改动全部展开 } };
// ================================================================ // 模块三:网页字体更换器(所有站点运行) // 模块三:题目列表「提交」快捷列 // 仅在以下页面运行: // - /contest/<hex>/problems (比赛题目列表) // - /p (题库) // - /p?page=<num> (题库分页) // - /homework/<hex> (作业题目列表) // - /training/<hex> (训练题目列表) // 在题目列表表格中新增一列「提交」,显示指向 /p/<id>/submit 的链接。 // 兼容所有 Hydro 系 OJ。 // ================================================================
const BZOJ_SubmitLinkModule = { /** 判断当前页面是否应该启用此模块 */ shouldRun: function () { const path = window.location.pathname; // /contest/<hex>/problems if (/\/contest\/[^\/]+\/problems\/?$/.test(path)) return true; // /p 或 /p?page=<num>(精确匹配 /p 结尾,排除 /p/<id> 详情页) if (/^\/p\/?$/.test(path)) return true; // /homework/<hex> if (/\/homework\/[^\/]+\/?$/.test(path)) return true; // /training/<hex> if (/\/training\/[^\/]+\/?$/.test(path)) return true; return false; },
init: function () { const self = this; if (!self.shouldRun()) return;
GM_addStyle(` .bzoj-submit-col-link { display: inline-block; padding: 2px 12px; border-radius: 4px; background: rgba(86,117,143,0.1); color: #56758f; font-size: 13px; font-weight: 600; text-decoration: none; font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif; transition: all .15s; } .bzoj-submit-col-link:hover { background: #56758f; color: #fff; text-decoration: none; } .theme--dark .bzoj-submit-col-link, html[data-mantine-color-scheme="dark"] .bzoj-submit-col-link { background: rgba(142,179,208,0.15); color: #8eb3d0; } .theme--dark .bzoj-submit-col-link:hover, html[data-mantine-color-scheme="dark"] .bzoj-submit-col-link:hover { background: #56758f; color: #fff; } `);
self.injectColumns();
// 监听 DOM 变化(Hydro 可能动态加载/重建表格) self._installObserver(); },
/** 判断一个 URL 是否是题目链接:/p/<id>(排除 submit 等子路径) */ isProblemLink: function (href) { if (!href) return false; if (/\/p\/[^\/]+\/(submit|solution|edit|files|manage)/.test(href)) return false; return /\/p\/[^\/]+/.test(href); },
/** 从题目链接 href 构建 submit URL(保留 tid 参数) */ buildSubmitUrl: function (href) { const url = new URL(href, location.href); return url.pathname.replace(/\/$/, '') + '/submit' + (url.search || ''); },
/** 在题目列表表格中新增「提交」列(不修改原有列,只在最右侧追加) */ injectColumns: function () { const self = this; // 第一步:移除页面中所有 Hydro 自带的「递交」链接(class="typo-a" 且指向 submit), // 这些链接通常是 float:right 的纯文字+图标,样式较陋,用我们新增的列替代。 // 独立于表格处理执行,确保即使行已被标记也能清理。 const allOldLinks = document.querySelectorAll('a.typo-a[href*="/submit"]'); for (const oldLink of allOldLinks) { oldLink.remove(); }
// 查找所有包含题目链接的表格 const tables = document.querySelectorAll('table.data-table'); let count = 0;
for (const table of tables) { if (table.dataset.bzojSubmitCol === '1') continue; // 已处理
const tbody = table.querySelector('tbody'); if (!tbody) continue;
// 检查表格是否包含题目链接(决定是否处理此表格) const rows = tbody.querySelectorAll('tr'); let hasProblemRow = false; for (const row of rows) { const link = row.querySelector('a[href*="/p/"]'); if (link && self.isProblemLink(link.getAttribute('href') || '')) { hasProblemRow = true; break; } } if (!hasProblemRow) continue;
// 找到表头行(thead > tr),也在表头加一列 let headerRow = null; const thead = table.querySelector('thead'); if (thead) headerRow = thead.querySelector('tr');
// Hydro 可能还有独立的 sticky 表头表(section__table-header),也要同步加列 let stickyHeaderRow = null; const container = table.closest('.section__body, .section, .problem-list-container, .col-container'); if (container) { const stickyTable = container.querySelector('table.section__table-header'); if (stickyTable) { const stickyThead = stickyTable.querySelector('thead'); if (stickyThead) stickyHeaderRow = stickyThead.querySelector('tr'); } }
// 同步 colgroup:如果有 <colgroup>,需要加一个 <col> 保持列数一致 const colgroup = table.querySelector('colgroup'); if (colgroup && !colgroup.dataset.bzojSubmitCol) { const col = document.createElement('col'); col.style.width = '80px'; colgroup.appendChild(col); colgroup.dataset.bzojSubmitCol = '1'; } // sticky 表头的 colgroup 也要同步 if (container) { const stickyTable = container.querySelector('table.section__table-header'); if (stickyTable) { const stickyColgroup = stickyTable.querySelector('colgroup'); if (stickyColgroup && !stickyColgroup.dataset.bzojSubmitCol) { const col = document.createElement('col'); col.style.width = '80px'; stickyColgroup.appendChild(col); stickyColgroup.dataset.bzojSubmitCol = '1'; } } }
// 在表头加一列「提交」 // 表头文字右对齐,padding-right 设为 28px(= td 的 16px + 按钮自身的 12px padding), // 使「提交」文字与下方按钮内文字的垂直中线对齐 if (headerRow && !headerRow.dataset.bzojSubmitHeader) { const th = document.createElement('th'); th.textContent = '提交'; th.style.cssText = 'text-align: right; white-space: nowrap; width: 80px; padding-right: 28px;'; headerRow.appendChild(th); headerRow.dataset.bzojSubmitHeader = '1'; } // sticky 表头也加一列 if (stickyHeaderRow && !stickyHeaderRow.dataset.bzojSubmitHeader) { const th = document.createElement('th'); th.textContent = '提交'; th.style.cssText = 'text-align: right; white-space: nowrap; width: 80px; padding-right: 28px;'; stickyHeaderRow.appendChild(th); stickyHeaderRow.dataset.bzojSubmitHeader = '1'; }
// 遍历所有行:有题目链接的加「提交」链接,无题目链接的(如 * 占位行)补空 td 保持列数一致 for (const row of rows) { if (row.dataset.bzojSubmitCell === '1') continue;
const link = row.querySelector('a[href*="/p/"]'); const isValidProblem = link && self.isProblemLink(link.getAttribute('href') || '');
const td = document.createElement('td'); td.style.cssText = 'text-align: right; white-space: nowrap; padding-right: 16px;'; if (isValidProblem) { // 有题目链接:加「提交」按钮 const href = link.getAttribute('href') || ''; const submitUrl = self.buildSubmitUrl(href); const a = document.createElement('a'); a.href = submitUrl; a.className = 'bzoj-submit-col-link'; a.textContent = '提交'; a.title = '递交此题'; a.target = link.target || '_self'; td.appendChild(a); count++; } else { // 无题目链接(如 * 占位行):补空 td,保持列数一致,不破坏行的灰色背景 td.innerHTML = ' '; } row.appendChild(td); row.dataset.bzojSubmitCell = '1'; }
table.dataset.bzojSubmitCol = '1'; } return count; },
_observer: null, _debounce: null, _installObserver: function () { const self = this; if (self._observer) return; self._observer = new MutationObserver(function () { clearTimeout(self._debounce); self._debounce = setTimeout(function () { self.injectColumns(); }, 300); }); self._observer.observe(document.body, { childList: true, subtree: true }); } };
// ================================================================ // 模块四:比赛/作业成绩表增强(scoreboard) // 适用页面: // - /contest/<hex>/scoreboard // - /homework/<hex>/scoreboard // 功能: // 1. 黄色高亮当前登录用户所在行 // 2. 对当前用户行的每道题,异步 fetch 该题的提交记录页面, // 提取最新一次提交的详细信息(状态、分数、耗时、内存), // 用直角状态方块显示在单元格内。 // 兼容所有 Hydro 系 OJ。 // ================================================================
const BZOJ_ScoreboardModule = { /** 状态信息(复用 testcase 模块的颜色定义,方块改为直角) */ STATUS_MAP: { 'accepted': { bg: '#f6ffed', text: 'AC', color: '#389e0d', border: '#b7eb8f' }, 'wrong answer': { bg: '#fff2f0', text: 'WA', color: '#cf1322', border: '#ffccc7' }, 'time limit exceeded': { bg: '#e6f7ff', text: 'TLE', color: '#0958d9', border: '#91d5ff' }, 'memory limit exceeded': { bg: '#e6f7ff', text: 'MLE', color: '#0958d9', border: '#91d5ff' }, 'runtime error': { bg: '#f9f0ff', text: 'RE', color: '#722ed1', border: '#d3adf7' }, 'compile error': { bg: '#fffbe6', text: 'CE', color: '#d48806', border: '#ffe58f' }, 'output limit exceeded': { bg: '#e6f7ff', text: 'OLE', color: '#0958d9', border: '#91d5ff' }, 'system error': { bg: '#f5f5f5', text: 'SE', color: '#434343', border: '#d9d9d9' }, 'judging': { bg: '#e6f7ff', text: '⟳', color: '#0958d9', border: '#91d5ff', spin: true }, 'compiling': { bg: '#e6f7ff', text: '⟳', color: '#0958d9', border: '#91d5ff', spin: true }, 'waiting': { bg: '#e6f7ff', text: '⟳', color: '#0958d9', border: '#91d5ff', spin: true }, 'running': { bg: '#e6f7ff', text: '⟳', color: '#0958d9', border: '#91d5ff', spin: true }, }, DARK_STATUS_MAP: { 'accepted': { bg: '#1e3a1e', text: 'AC', color: '#95de64', border: '#389e0d' }, 'wrong answer': { bg: '#3d1f22', text: 'WA', color: '#ff9c9c', border: '#a8071a' }, 'time limit exceeded': { bg: '#1a2d42', text: 'TLE', color: '#69c0ff', border: '#003a8c' }, 'memory limit exceeded': { bg: '#1a2d42', text: 'MLE', color: '#69c0ff', border: '#003a8c' }, 'runtime error': { bg: '#2d1f3d', text: 'RE', color: '#c9a0f5', border: '#531dab' }, 'compile error': { bg: '#3d321e', text: 'CE', color: '#ffd666', border: '#ad6800' }, 'output limit exceeded': { bg: '#1a2d42', text: 'OLE', color: '#69c0ff', border: '#003a8c' }, 'system error': { bg: '#2e2e2e', text: 'SE', color: '#d9d9d9', border: '#434343' }, },
/** 判断当前页面是否是成绩表页 */ shouldRun: function () { const path = window.location.pathname; return /\/(contest|homework)\/[^\/]+\/scoreboard\/?$/.test(path); },
/** 从 URL 提取 tid(比赛/作业 ID) */ getTid: function () { const m = window.location.pathname.match(/\/(contest|homework)\/([^\/]+)\/scoreboard/); return m ? m[2] : ''; },
/** 检测暗色模式 */ isDarkMode: function () { const html = document.documentElement; if (html.classList.contains('theme--dark')) return true; if (html.classList.contains('theme--light')) return false; if (html.getAttribute('data-mantine-color-scheme') === 'dark') return true; if (html.getAttribute('data-mantine-color-scheme') === 'light') return false; try { const bgColor = getComputedStyle(document.body).backgroundColor; const match = bgColor.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/); if (match) { return (0.299 * +match[1] + 0.587 * +match[2] + 0.114 * +match[3]) / 255 < 0.5; } } catch (e) {} return false; },
/** 获取当前登录用户的 uid */ getCurrentUid: function () { // Hydro 导航栏: nav .nav__list--secondary a[href^="/user/"] const userLink = document.querySelector('nav .nav__list--secondary a[href^="/user/"]'); if (userLink) { const m = userLink.getAttribute('href').match(/\/user\/(\w+)/); if (m) return m[1]; } // 兜底 const altLink = document.querySelector('a[href^="/user/"][class*="user-profile"], a.uname[href^="/user/"]'); if (altLink) { const m = altLink.getAttribute('href').match(/\/user\/(\w+)/); if (m) return m[1]; } return null; },
init: function () { const self = this; if (!self.shouldRun()) return;
GM_addStyle(` /* 当前用户行高亮 */ .bzoj-scoreboard-highlight { background-color: rgba(255, 230, 0, 0.25) !important; } .theme--dark .bzoj-scoreboard-highlight, html[data-mantine-color-scheme="dark"] .bzoj-scoreboard-highlight { background-color: rgba(255, 200, 0, 0.18) !important; } /* 详细状态方块(直角,填满单元格,契合表格) */ .bzoj-score-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; box-sizing: border-box; padding: 4px 2px; border: 1px solid; border-radius: 0; font-family: system-ui, -apple-system, sans-serif; font-weight: 600; line-height: 1.2; cursor: default; transition: transform 0.1s; text-decoration: none; } .bzoj-score-cell:hover { transform: scale(1.05); } /* 让 td 本身也成为 flex 容器,确保方块填满 */ td.col--problem:has(.bzoj-score-cell) { padding: 2px !important; } .bzoj-score-cell__text { font-size: 11px; font-weight: 700; } .bzoj-score-cell__score { font-size: 13px; font-weight: 700; } .bzoj-score-cell__detail { font-size: 9px; font-weight: 400; opacity: 0.8; white-space: nowrap; } @keyframes bzoj-score-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .bzoj-score-cell__text--spin { animation: bzoj-score-spin 1.5s linear infinite; } /* 加载中占位 */ .bzoj-score-loading { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(86,117,143,0.2); border-top-color: #56758f; border-radius: 50%; animation: bzoj-score-spin 0.8s linear infinite; } `);
self.enhanceScoreboard(); self._installObserver(); },
/** 标准化状态文本 */ normalizeStatus: function (raw) { if (!raw) return ''; const text = raw.trim().toLowerCase(); const aliases = { 'time exceeded': 'time limit exceeded', 'memory exceeded': 'memory limit exceeded', 'ac': 'accepted', 'wa': 'wrong answer', 'tle': 'time limit exceeded', 'mle': 'memory limit exceeded', 're': 'runtime error', 'ce': 'compile error', 'ole': 'output limit exceeded', 'se': 'system error', }; if (aliases[text]) return aliases[text]; for (const key of Object.keys(this.STATUS_MAP)) { if (text.includes(key)) return key; } return text; },
/** 获取状态信息 */ getStatusInfo: function (key) { const isDark = this.isDarkMode(); const map = isDark ? this.DARK_STATUS_MAP : this.STATUS_MAP; return map[key] || { bg: isDark ? '#2e2e2e' : '#f5f5f5', text: key.substring(0, 3).toUpperCase(), color: isDark ? '#d9d9d9' : '#434343', border: isDark ? '#434343' : '#d9d9d9', }; },
/** 从表头提取每道题的 pid 列表 */ extractProblemIds: function () { // Hydro 成绩表表头在独立的 sticky 表 (table.section__table-header) 或同表 thead const headerLinks = document.querySelectorAll( 'table.section__table-header thead th.col--problem a[href*="/p/"], ' + 'table thead th.col--problem a[href*="/p/"]' ); const pids = []; for (const a of headerLinks) { const m = a.getAttribute('href').match(/\/p\/([^\/?]+)/); if (m) pids.push(m[1]); } return pids; },
/** 增强成绩表:高亮当前用户行 + 异步加载提交详情 */ enhanceScoreboard: function () { const self = this; const uid = self.getCurrentUid(); const tid = self.getTid();
// 查找成绩表 tbody(Hydro 用 table.data-table,tbody 里有行) const tables = document.querySelectorAll('table.data-table'); for (const table of tables) { const tbody = table.querySelector('tbody'); if (!tbody) continue; const rows = tbody.querySelectorAll('tr'); if (rows.length === 0) continue; // 检查是否是成绩表(有 col--rank / col--user 列) if (!table.querySelector('col.col--rank, col.col--user, td.col--rank, td.col--user')) continue; if (table.dataset.bzojScoreboard === '1') continue; table.dataset.bzojScoreboard = '1';
// 提取每题 pid(从表头) const pids = self.extractProblemIds();
for (const row of rows) { if (row.dataset.bzojScoreRow === '1') continue; row.dataset.bzojScoreRow = '1';
// 高亮当前用户行 if (uid) { const userBtn = row.querySelector('[data-uid]'); const userLink = row.querySelector('a[href^="/user/"]'); let rowUid = null; if (userBtn) rowUid = userBtn.getAttribute('data-uid'); else if (userLink) { const m = userLink.getAttribute('href').match(/\/user\/(\w+)/); if (m) rowUid = m[1]; } if (rowUid && rowUid === uid) { row.classList.add('bzoj-scoreboard-highlight'); // 对当前用户行,异步加载每题提交详情 self._loadUserSubmissionDetails(row, uid, tid, pids); } } } } },
/** 异步加载当前用户每道题的提交详情 */ _loadUserSubmissionDetails: async function (row, uid, tid, pids) { const self = this; // 获取当前行的题目单元格(col--problem) const problemCells = row.querySelectorAll('td.col--problem'); if (problemCells.length === 0) return;
// 为每个题目单元格先放加载占位 problemCells.forEach((cell, idx) => { if (cell.querySelector('.bzoj-score-cell, .bzoj-score-loading')) return; // 保留原始分数文本 const originalScore = cell.textContent.trim(); cell.dataset.bzojOriginalScore = originalScore; const loader = document.createElement('span'); loader.className = 'bzoj-score-loading'; cell.innerHTML = ''; cell.appendChild(loader); });
// 逐题 fetch 提交记录 for (let i = 0; i < problemCells.length && i < pids.length; i++) { const cell = problemCells[i]; const pid = pids[i]; try { await self._fetchAndShowDetail(cell, pid, uid, tid); } catch (e) { self._restoreCell(cell); } } },
/** fetch 单题提交记录,提取最新提交的 record 链接,再 fetch record 详情 */ _fetchAndShowDetail: async function (cell, pid, uid, tid) { const self = this; // Hydro 提交记录列表: /record?pid=<pid>&uidOrName=<uid>&tid=<tid> const listUrl = `/record?pid=${encodeURIComponent(pid)}&uidOrName=${encodeURIComponent(uid)}${tid ? '&tid=' + tid : ''}`; const resp = await fetch(listUrl, { credentials: 'same-origin' }); const html = await resp.text(); const doc = new DOMParser().parseFromString(html, 'text/html');
// 找到第一条提交记录的链接 /record/<rid> const recordLink = doc.querySelector('a[href^="/record/"]'); if (!recordLink) { self._restoreCell(cell); return; } const ridMatch = recordLink.getAttribute('href').match(/\/record\/(\w+)/); if (!ridMatch) { self._restoreCell(cell); return; } const rid = ridMatch[1];
// fetch record 详情页 const recordUrl = `/record/${rid}`; const resp2 = await fetch(recordUrl, { credentials: 'same-origin' }); const html2 = await resp2.text(); const doc2 = new DOMParser().parseFromString(html2, 'text/html');
// 从 record 页面提取状态、分数、耗时、内存 const detail = self._extractRecordDetail(doc2); self._renderDetailCell(cell, detail, recordUrl); },
/** 从 record 详情页提取状态/分数/耗时/内存 * 页面结构: * 顶栏 #status .section__title 内含 .record-status--text(状态文字,如 Accepted) * 和 .float-right 或无 class 的 span(分数,如 60) * 侧边栏 #summary 的 dl.horizontal 内: * <dt>分数</dt><dd>60</dd> * <dt>总耗时</dt><dd>39ms</dd> * <dt>峰值时间</dt><dd>1ms</dd> * <dt>峰值内存</dt><dd>768 KiB</dd> */ _extractRecordDetail: function (doc) { const self = this;
// 状态:顶栏的 .record-status--text(排除 .float-right 分数部分) let statusKey = ''; const statusEls = doc.querySelectorAll('#status .record-status--text, .record-status--text'); for (const el of statusEls) { // 克隆后移除 .float-right 子元素,只取状态文字 const clone = el.cloneNode(true); clone.querySelectorAll('.float-right').forEach(e => e.remove()); const text = clone.textContent.trim(); if (text) { statusKey = self.normalizeStatus(text); if (statusKey) break; } }
// 从 #summary 的 dl.horizontal 提取分数/时间/内存 let score = '', time = '', memory = ''; const summaryDl = doc.querySelector('#summary, dl#summary'); if (summaryDl) { const dts = summaryDl.querySelectorAll('dt'); const dds = summaryDl.querySelectorAll('dd'); for (let i = 0; i < dts.length && i < dds.length; i++) { const label = dts[i].textContent.trim().toLowerCase(); const value = dds[i].textContent.trim(); if (label === '分数' || label === 'score') { score = value; } else if (label === '峰值时间' || label === '总耗时' || label.includes('时间') || label.includes('time')) { if (!time) time = value; // 优先取峰值时间/总耗时 } else if (label === '峰值内存' || label.includes('内存') || label.includes('memory')) { memory = value; } } }
// 兜底:分数从顶栏 .float-right 或 section__title 提取 if (!score) { const floatRight = doc.querySelector('#status .float-right, .record-status--text .float-right'); if (floatRight) { score = floatRight.textContent.trim(); } } if (!score) { const titleEl = doc.querySelector('#status .section__title'); if (titleEl) { const m = titleEl.textContent.match(/(\d+)/); if (m) score = m[1]; } }
return { statusKey, score, time, memory }; },
/** 渲染详细状态方块到单元格 */ _renderDetailCell: function (cell, detail, recordUrl) { const self = this; const originalScore = cell.dataset.bzojOriginalScore || ''; cell.innerHTML = '';
if (!detail.statusKey && !detail.score && !originalScore) { self._restoreCell(cell); return; }
const statusKey = detail.statusKey || ''; const info = statusKey ? self.getStatusInfo(statusKey) : { bg: this.isDarkMode() ? '#2e2e2e' : '#f5f5f5', text: '', color: this.isDarkMode() ? '#d9d9d9' : '#434343', border: this.isDarkMode() ? '#434343' : '#d9d9d9', };
const block = document.createElement('a'); block.href = recordUrl; block.target = '_blank'; block.className = 'bzoj-score-cell'; block.style.background = info.bg; block.style.color = info.color; block.style.borderColor = info.border;
// 状态缩写 if (info.text) { const textEl = document.createElement('span'); textEl.className = 'bzoj-score-cell__text'; if (info.spin) textEl.classList.add('bzoj-score-cell__text--spin'); textEl.textContent = info.text; block.appendChild(textEl); } // 分数 const scoreVal = detail.score || originalScore; if (scoreVal) { const scoreEl = document.createElement('span'); scoreEl.className = 'bzoj-score-cell__score'; scoreEl.textContent = scoreVal; block.appendChild(scoreEl); } // 耗时 / 内存 if (detail.time || detail.memory) { const detailEl = document.createElement('span'); detailEl.className = 'bzoj-score-cell__detail'; detailEl.textContent = [detail.time, detail.memory].filter(Boolean).join(' / '); block.appendChild(detailEl); } cell.appendChild(block); },
/** 恢复原始分数显示 */ _restoreCell: function (cell) { const original = cell.dataset.bzojOriginalScore; if (original !== undefined) { cell.innerHTML = ''; cell.textContent = original; } },
_observer: null, _debounce: null, _installObserver: function () { const self = this; if (self._observer) return; self._observer = new MutationObserver(function () { clearTimeout(self._debounce); self._debounce = setTimeout(function () { self.enhanceScoreboard(); }, 500); }); self._observer.observe(document.body, { childList: true, subtree: true }); } };
// ================================================================ // 模块五:网页字体更换器(所有站点运行) // ================================================================
// ==================== 默认常量 ====================
const FS_DEFAULT_BTN_SIZE = 42; const FS_COLLAPSED_VISIBLE = 6;1,650 行未改动全部展开 fsResetIdleTimer(); }
// ================================================================ // 主入口:初始化三个模块 // 主入口:初始化五个模块 // ================================================================
function main() { // 字体更换器:所有站点运行3 行未改动 BZOJ_TestcaseModule.init();
// BZOJ 题目 Markdown 查看/复制:仅 /p/<id> 题目详情页运行(init 内部有路径与结构双重判断) BZOJ_ProblemMarkdownModule.init();
// BZOJ 题目列表「提交」快捷列:仅题库/比赛/作业/训练列表页运行 BZOJ_SubmitLinkModule.init();
// BZOJ 成绩表增强:仅 /contest/<hex>/scoreboard 和 /homework/<hex>/scoreboard 运行 BZOJ_ScoreboardModule.init(); }
if (document.readyState === 'complete' || document.readyState === 'interactive') { main(); } else { document.addEventListener('DOMContentLoaded', main); }
})();``````text1.我说的是ctrl+鼠标滚轮要缩放窗口大小 2.应该询问用户为不是直接读取对话,不然有时很烦3.{ "error": "Error code: 400, with error text {\"error\":{\"code\":\"1214\",\"message\":\"messages 参数非法。请检查文档。\"}}", "timestamp": "2026-06-29T16:32:18.331372", "model": "glm-4.7-flash", "cwd": "D:\\sublime", "active_skills": [], "total_tokens_estimate": 4654, "messages_count": 15, "messages": [ { "index": 0, "role": "system", "content_length": 2051, "content_preview": "你是一个运行在 Windows 命令行环境下的高级智能 Agent。\n你不仅能够回答问题,还能通过调用工具来帮用户完成实际任务。\n\n## 可用工具\n\n你可以通过 Function Calling 调用以下工具:\n\n1. run_cmd - 执行 Windows CMD 命令。适合简单系统命令(dir, ipconfig, tasklist, ping 等)\n - 可选参数 input: 如果命令需要交互式输入(如确认 Y/N、选择项等),通过此参数预先提供,用换行符分隔多行输入\n2. run_powershell - 执行 PowerShell 命令。适合复杂查询、对象管道、格式化输出\n - 可选参数 input: 同上\n3. run_python - 执行 Python 代码片段。适合数学计算、数据处理、批量操作\n - 可选参数 input: 如果代码中调用了 input(),通过此参数预先提供输入值\n4. write_file - 写入文件。创建或覆盖文件内容\n5. read_file - 读取文件。查看文件内容\n\n## 工具选择策略\n\n- 简单系统命令 -> run_" }, { "index": 1, "role": "assistant", "content_length": 18, "content_preview": "我来重新读取所有文件并给出详细总结。", "tool_calls_count": 14, "tool_calls_details": [ { "index": 0, "id": "call_b39bc752d87a482bb1a8bd1a", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"123.mycraftsave\\\"\"}", "arguments_is_valid_json": true }, { "index": 1, "id": "call_a018079efc584e1eba966772", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"a.bf\\\"\"}", "arguments_is_valid_json": true }, { "index": 2, "id": "call_937a02b614eb475783eb10b7", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"a.cpp\\\"\"}", "arguments_is_valid_json": true }, { "index": 3, "id": "call_91a8c83d11664c708d8ee2fb", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"a.md\\\"\"}", "arguments_is_valid_json": true }, { "index": 4, "id": "call_09486aeb768a44068fa063a2", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"a.py\\\"\"}", "arguments_is_valid_json": true }, { "index": 5, "id": "call_841f4a6e50434d00b5874437", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"a.txt\\\"\"}", "arguments_is_valid_json": true }, { "index": 6, "id": "call_5956551653bc4b18acca03a1", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"bf.cpp\\\"\"}", "arguments_is_valid_json": true }, { "index": 7, "id": "call_581b9ae5569d4f86826f883a", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"bzoj.cpp\\\"\"}", "arguments_is_valid_json": true }, { "index": 8, "id": "call_1dbe27156be1416aad7586a0", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"main.cpp\\\"\"}", "arguments_is_valid_json": true }, { "index": 9, "id": "call_13c87d6934d743669a091db0", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"ray.cpp\\\"\"}", "arguments_is_valid_json": true }, { "index": 10, "id": "call_a4339a3c734d495e8fffe73b", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"run.cpp\\\"\"}", "arguments_is_valid_json": true }, { "index": 11, "id": "call_5e38b433d64143e787479f3b", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"s.cpp\\\"\"}", "arguments_is_valid_json": true }, { "index": 12, "id": "call_2e870ed072d245efbd0603da", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"u.cpp\\\"\"}", "arguments_is_valid_json": true }, { "index": 13, "id": "call_3511421688e541019bd4b7fb", "function_name": "run_powershell", "arguments_raw": "{\"command\":\"Get-Content \\\"yhr.h\\\"\"}", "arguments_is_valid_json": true } ] }, { "index": 2, "role": "tool", "content_length": 6014, "content_preview": "0 173 0 91 72 4 0 100 68 0 2 0 0 63 0 0 0 0 0 0 2 10 20\n\nEMpPMIO0oDWCtzWJ\n =*#+x$0*\n0 0 0 0 0 0 0 0 0 \n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "tool_call_id": "call_b39bc752d87a482bb1a8bd1a", "has_parent_assistant": true }, { "index": 3, "role": "tool", "content_length": 5, "content_preview": "(无输出)", "tool_call_id": "call_a018079efc584e1eba966772", "has_parent_assistant": true }, { "index": 4, "role": "tool", "content_length": 5, "content_preview": "(无输出)", "tool_call_id": "call_937a02b614eb475783eb10b7", "has_parent_assistant": true }, { "index": 5, "role": "tool", "content_length": 5, "content_preview": "(无输出)", "tool_call_id": "call_91a8c83d11664c708d8ee2fb", "has_parent_assistant": true }, { "index": 6, "role": "tool", "content_length": 5, "content_preview": "(无输出)", "tool_call_id": "call_09486aeb768a44068fa063a2", "has_parent_assistant": true }, { "index": 7, "role": "tool", "content_length": 5, "content_preview": "(无输出)", "tool_call_id": "call_841f4a6e50434d00b5874437", "has_parent_assistant": true }, { "index": 8, "role": "tool", "content_length": 5, "content_preview": "(无输出)", "tool_call_id": "call_5956551653bc4b18acca03a1", "has_parent_assistant": true }, { "index": 9, "role": "tool", "content_length": 350, "content_preview": "#include<bits/stdc++.h>\nusing namespace std;\n#define int long long\nint n,b[200004],c[200005],dp[2][200005];\nstruct node{\n int w,p;\n};\nvector<node>dp1;\nsigned main(){\n cin>>n;\n for(int i=1;i<=n;i++)cin>>b[i];\n for(int i=1;i<=n;i++)cin>>c[i];\n for(int i=1;i<=n;i++){\n int k=log(c[i]);\n if(c[i]-(1<<k))\n }\n return 0;\n}", "tool_call_id": "call_581b9ae5569d4f86826f883a", "has_parent_assistant": true }, { "index": 10, "role": "tool", "content_length": 5, "content_preview": "(无输出)", "tool_call_id": "call_1dbe27156be1416aad7586a0", "has_parent_assistant": true }, { "index": 11, "role": "tool", "content_length": 6014, "content_preview": "#include<vector>\n#include<math.h>\n#include<string>\n#include<iostream>\n#include<algorithm>\n#include<conio.h>\n#include<time.h>\n#include\"raylib.h\"\n#include\"raymath.h\"\nusing namespace std;\nstruct node{\n Vector2 pos;\n int isend;\n Color col;\n bool operator ==(const node&other)const{\n return Vector2Equals(pos,other.pos);\n }\n};\nColor operator ~(const Color&me){\n return Color{(unsigned char)~me.r,(unsigned char)~me.g,(unsigned char)~me.b,255};\n}\nvector<node> redo;\nvector<node> po", "tool_call_id": "call_13c87d6934d743669a091db0", "has_parent_assistant": true }, { "index": 12, "role": "tool", "content_length": 343, "content_preview": "#include<bits/stdc++.h>\nusing namespace std;\n#define int long long\nsigned main(){\n string a;\n cin>>a;\n int c;\n cin>>c;\n srand(c);\n int x[8];\n for(int i=0;i<8;i++){\n x[i]=c&0x7f;\n while(x[i]<=32)x[i]=rand()&0x7f;\n c<<=8;\n }\n for(int i=0;i<a.length();i++)a[i]^=x[i%8];\n cout<<a;\n return 0;\n}", "tool_call_id": "call_a4339a3c734d495e8fffe73b", "has_parent_assistant": true }, { "index": 13, "role": "tool", "content_length": 1731, "content_preview": "#define WIN32_LEAN_AND_MEAN\n#include<bits/stdc++.h>\n#include<windows.h>\n#include<conio.h>\nusing namespace std;\nusing namespace std::chrono;\nconst int len=40;\nstruct color{\n unsigned char r,g,b;\n};\ncolor mp[len][len];\ninline long long mms(){\n return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();\n}\nvoid Sleepp(int m){\n long long start=mms();\n while(1){\n long long e=mms()-start;\n if(e>=m)break;\n }\n}\nvoid start(){\n HANDLE hConsole=GetStdH", "tool_call_id": "call_5e38b433d64143e787479f3b", "has_parent_assistant": true }, { "index": 14, "role": "tool", "content_length": 5, "content_preview": "(无输出)", "tool_call_id": "call_2e870ed072d245efbd0603da", "has_parent_assistant": true } ], "tools": [ { "type": "function", "function": { "name": "run_cmd", "description": "在 Windows CMD 中执行命令并返回输出。适合简单的系统命令如 dir、ipconfig、tasklist 等。如果命令需要交互式输入(如确认提示 Y/N、密码、选择项等),请通过 input 参数预先提供输入内容,每行一个输入用换行符分隔。", "parameters": { "type": "object", "properties": { "command": { "type": "string", "description": "要执行的 Windows CMD 命令,如 'dir C:\\Users' 或 'ipconfig /all'" }, "input": { "type": "string", "description": "预先提供给命令的标准输入(stdin)内容。如果命令会等待用户输入(如确认提示 Y/N、密码、菜单选择等),将输入内容写在这里,每行一个输入,用换行符分隔。例如: 'Y' 或 'yes\\nno'。如果命令不需要输入则不要填写此参数。" } }, "required": [ "command" ] } } }, { "type": "function", "function": { "name": "run_powershell", "description": "在 PowerShell 中执行命令并返回输出。适合需要对象管道、格式化输出、复杂查询等场景。如果命令需要交互式输入,请通过 input 参数预先提供。", "parameters": { "type": "object", "properties": { "command": { "type": "string", "description": "要执行的 PowerShell 命令,如 'Get-Process | Sort-Object CPU -Descending | Select-Object -First 5'" }, "input": { "type": "string", "description": "预先提供给命令的标准输入内容。如果命令会等待用户输入,将输入内容写在这里,每行一个输入用换行符分隔。不需要输入则不要填写此参数。" } }, "required": [ "command" ] } } }, { "type": "function", "function": { "name": "run_python", "description": "执行 Python 代码片段并返回输出。适合数学计算、数据处理、文件批量操作等需要编程逻辑的场景。如果代码中调用了 input(),请通过 input 参数预先提供输入值,每行一个用换行符分隔。", "parameters": { "type": "object", "properties": { "code": { "type": "string", "description": "要执行的 Python 代码片段,如 'import os; print(os.listdir(\".\"))'" }, "input": { "type": "string", "description": "预先提供给 Python 脚本的标准输入内容。如果代码中调用了 input(),将对应的输入值写在这里,每行一个输入用换行符分隔。不需要输入则不要填写此参数。" } }, "required": [ "code" ] } } }, { "type": "function", "function": { "name": "write_file", "description": "将内容写入指定文件。如果文件已存在则覆盖,如果父目录不存在则自动创建。", "parameters": { "type": "object", "properties": { "path": { "type": "string", "description": "文件路径,如 'C:\\Users\\test\\hello.txt'" }, "content": { "type": "string", "description": "要写入文件的内容" } }, "required": [ "path", "content" ] } } }, { "type": "function", "function": { "name": "read_file", "description": "读取指定文件的内容并返回。支持文本文件,大文件会自动截断。", "parameters": { "type": "object", "properties": { "path": { "type": "string", "description": "文件路径,如 'C:\\Users\\test\\hello.txt'" } }, "required": [ "path" ] } } } ]}还是没用```