版本比较
洛谷题目转 PDF
正文
增加 357 行删除 123 行
27 行未改动282930313233323334353636373839404142434344444546474849505152535455565758596061626364656667686970717273567475767778798081826667686983848586878889909178929394959684979899100101102103921041051061071085 行未改动11411511611711811912012112212312411211311411512512612712812912012113013113213313426 行未改动1611621631641561571581591651661671681631691701711721731741751761771781731791801761771781811821831841851861874 行未改动1921931941951911961971981994 行未改动2042052062072042052062072082092102112122132142152162172082092102112122212132142152162172182192202212222232232242252262262272282292302312322282292302312322332342352362372412382392402412462422432442452463 行未改动2502512522532542582552562572582592602612622662632642652662672 行未改动27027127227327727827427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149228049349449549649749849928450050150250350450550650750850951051151251351451551651751851952052152252352452528652652752852928929053053153253353453553653753853929454054154254329854454554630154754854955014 行未改动5655665675683245695705715725735745755765775783345793363373383393403413423433443453463473483493503513525805813553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883895825835845853943955865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436 行未改动65065165265342065465542265627 行未改动```javascript// ==UserScript==// @name 洛谷题目转 PDF// @namespace http://tampermonkey.net/// @version 3.9.2// @description 从JSON重建页面,渲染Markdown和LaTeX,正确缩进每段;检测到submit页面时不执行,按钮始终可用// @version 5.2.7// @description 从JSON重建页面,修复题目背景、合并表格、编号加粗、特殊性质对齐等问题,已修复XSS漏洞// @match https://www.luogu.com.cn/problem/*// @require https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js// @require https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js// @require https://cdn.jsdelivr.net/npm/marked/marked.min.js// @require https://cdn.jsdelivr.net/npm/dompurify@3.0.6/dist/purify.min.js// @grant GM_addStyle// ==/UserScript==
(function () { "use strict";
if (typeof renderMathInElement === 'undefined') { console.error('[Luogu-RER] 致命错误:KaTeX auto-render 未加载'); if (typeof katex === 'undefined') { console.error('[Luogu-RER] 致命错误:KaTeX 核心库未加载'); return; } if (typeof marked === 'undefined') { console.error('[Luogu-RER] 致命错误:marked 未加载'); return; } if (typeof DOMPurify === 'undefined') { console.error('[Luogu-RER] 致命错误:DOMPurify 未加载'); return; }
marked.setOptions({ breaks: true, gfm: true });
// HTML 转义函数,用于防止 XSS function escapeHtml(str) { const div = document.createElement('div'); div.textContent = str; return div.innerHTML; }
window.addEventListener('load', () => { setTimeout(MainScript, 500); });
function MainScript() { const path = window.location.pathname; if (!/^\/problem\/[PBCFSPATU]/.test(path)) return;
// 检测到 submit/solution 等 hash 时不渲染,防止把提交页面洗白 const hash = window.location.hash.toLowerCase(); if (hash.includes('submit') || hash.includes('solution')) { console.log('[Luogu-RER] 检测到提交/题解页面,跳过渲染'); return; }
console.log("[Luogu-RER] 开始...");
// ---------- 1. 提取原始按钮 ---------- let submitBtn = null; let copyBtn = null; let solutionBtn = null;
let submitBtn = null, copyBtn = null, solutionBtn = null; const sidebar = document.querySelector('.sidebar-container .side'); if (sidebar) { sidebar.querySelectorAll('button, a').forEach(el => { const text = el.textContent.trim(); if (text === '提交') submitBtn = el; else if (text.includes('题解')) solutionBtn = el; }); }
if (!submitBtn) { document.querySelectorAll('button, a').forEach(el => { if (el.textContent.trim() === '提交') submitBtn = el; }); }
const actionContainer = document.querySelector('.problem-block-actions'); if (actionContainer) { actionContainer.querySelectorAll('button, a').forEach(btn => { if (btn.textContent.trim().includes('复制 Markdown')) copyBtn = btn; }); }
console.log('[Luogu-RER] 原始按钮捕获:提交=' + !!submitBtn + ' 复制=' + !!copyBtn + ' 题解=' + !!solutionBtn); console.log('[Luogu-RER] 按钮:提交=' + !!submitBtn + ' 复制=' + !!copyBtn + ' 题解=' + !!solutionBtn);
// ---------- 2. 读取题目数据 ---------- const contextScript = document.querySelector('#lentille-context'); if (!contextScript) { console.error("[Luogu-RER] 找不到题目数据"); return; }5 行未改动 const pid = problemData.pid; const name = problemData.name; const content = problemData.content || {}; const desc = content.description || ''; const background = content.background || ''; const fmtIn = content.formatI || ''; const fmtOut = content.formatO || ''; const hint = content.hint || ''; const samples = problemData.samples || []; const limits = problemData.limits || {};
// 处理时间/内存限制 function getFirstValid(raw) { return Array.isArray(raw) ? raw[0] : raw; } function getFirstValid(raw) { return Array.isArray(raw) ? raw[0] : raw; } function formatTime(raw) { const val = getFirstValid(raw); if (val === undefined || val === null || val === '') return ''; const num = Number(val); if (!isNaN(num) && num > 0) return (num / 1000).toFixed(2) + 's'; return String(val); return (!isNaN(num) && num > 0) ? (num / 1000).toFixed(2) + 's' : String(val); } function formatMemory(raw) { const val = getFirstValid(raw); if (val === undefined || val === null || val === '') return '';26 行未改动
mainContainer.innerHTML = ''; mainContainer.style.cssText = 'margin:12px auto;width:100%;max-width:1191px;padding:0;';
BuildPage(mainContainer, { pid, name, desc, fmtIn, fmtOut, hint, samples, hidden, timeLimit, memoryLimit }); BuildPage(mainContainer, { pid, name, desc, background, fmtIn, fmtOut, hint, samples, hidden, timeLimit, memoryLimit }); }
function BuildPage(container, data) { // ---- 顶部工具栏 ---- // 工具栏 const toolbar = document.createElement('div'); toolbar.id = 'Custom-toolbar'; toolbar.style.cssText = ` position:sticky;top:0;z-index:1000;background:#2c3e50;color:#fff; display:flex;align-items:center;justify-content:space-between; padding:0 20px;height:48px;box-shadow:0 2px 8px rgba(0,0,0,0.2); font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; flex-wrap:wrap;gap:6px; `;
const leftDiv = document.createElement('div'); leftDiv.style.cssText = 'display:flex;align-items:center;gap:10px;font-size:15px;'; leftDiv.innerHTML = `<span style="font-weight:700;color:#61dafb">${data.pid}</span> <span style="color:#ecf0f1;max-width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${data.name}</span>`;
// 对 pid 和 name 进行 HTML 转义 leftDiv.innerHTML = `<span style="font-weight:700;color:#61dafb">${escapeHtml(data.pid)}</span> <span style="color:#ecf0f1;max-width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${escapeHtml(data.name)}</span>`; const rightDiv = document.createElement('div'); rightDiv.style.cssText = 'display:flex;align-items:center;gap:4px;flex-wrap:wrap;';
const hiddenBtns = data.hidden.querySelectorAll('button, a');4 行未改动 else if (t.includes('复制 Markdown')) hCopy = el; else if (t.includes('题解')) hSolution = el; });
// ===== 核心修改:按钮始终可用,无原始按钮时用备用功能 ===== const mkBtn = (label, hiddenBtn, cls) => { const b = document.createElement('button'); b.textContent = label; b.className = 'tb-btn' + (cls ? ' ' + cls : '');4 行未改动 transition:0.2s;white-space:nowrap; `; if (cls === 'tb-submit') b.style.background='#3498db';
// 如果捕获到了原始按钮,直接模拟点击 if (hiddenBtn) { b.onclick = e => { e.preventDefault(); try { hiddenBtn.click(); } catch (err) { console.error('[Luogu-RER] 模拟点击失败', err); } }; return b; }
// 没有原始按钮时的备用方案 b.onclick = e => { e.preventDefault();
// 提交按钮:直接跳转 submit 并刷新 if (label === '提交') { // 直接跳转到 hash submit,脚本会自动跳过渲染 window.location.hash = 'submit'; window.location.reload(); return; }
// 其他按钮:如果存在原始按钮则触发,否则按类型处理 if (hiddenBtn) { try { hiddenBtn.click(); } catch (err) { console.error(err); } return; }
} else if (label === '题解') { if (label === '题解') { window.location.hash = 'solution'; } else if (label.includes('复制 Markdown')) { // 自行复制题目内容 const content = document.querySelector('#Problem-element')?.innerText || ''; navigator.clipboard.writeText(content).then(() => { alert('Markdown 文本已复制到剪贴板'); }).catch(() => { alert('复制失败,请手动选择文本'); }); navigator.clipboard.writeText(content).then(() => alert('已复制')).catch(() => alert('复制失败')); } };
return b; };
rightDiv.appendChild(mkBtn('提交', hSubmit, 'tb-submit')); rightDiv.appendChild(mkBtn('复制 Markdown', hCopy)); rightDiv.appendChild(mkBtn('题解', hSolution));
toolbar.appendChild(leftDiv); toolbar.appendChild(rightDiv); container.appendChild(toolbar);
// ---- 题目内容区(后面完全不变) ---- // 题目内容区 const problemDiv = document.createElement('div'); problemDiv.id = 'Problem-element'; problemDiv.style.cssText = ` color:#000;background:#fff;padding:77px 141px 156px;box-shadow:0 1px 10px rgba(0,0,0,0.1);3 行未改动
// 头部 const hdr = document.createElement('header'); hdr.style.cssText = 'font-size:20px;display:flex;flex-wrap:wrap;margin-bottom:48px;font-family:KaTeX_Main,SimSun,serif;'; // 对 pid 和 name 进行 HTML 转义 hdr.innerHTML = `<div style="margin-right:auto">洛谷 Luogu</div><div>${data.pid} ${data.name}</div><hr style="flex-basis:100%;border:1px solid #bfbfbf;margin:0">`; hdr.innerHTML = `<div style="margin-right:auto">洛谷 Luogu</div><div>${escapeHtml(data.pid)} ${escapeHtml(data.name)}</div><hr style="flex-basis:100%;border:1px solid #bfbfbf;margin:0">`; problemDiv.appendChild(hdr);
const title = document.createElement('h1'); title.textContent = data.name; title.style.cssText = 'text-align:center;font-size:36px;margin:37px 0 12px 0;font-weight:normal;font-family:KaTeX_Main,SimHei,sans-serif'; problemDiv.appendChild(title);
// 时间/内存限制 // 时间/内存 if (data.timeLimit || data.memoryLimit) { const limitsDiv = document.createElement('div'); limitsDiv.style.cssText = 'text-align:center;font-size:18px;color:#666;margin-bottom:24px;font-family:KaTeX_Main,SimHei,sans-serif;'; let parts = [];2 行未改动 limitsDiv.textContent = parts.join(' '); problemDiv.appendChild(limitsDiv); }
// 辅助函数:解析Markdown并插入,同时为所有<p>设置缩进 function appendMarkdown(md) { // ========== 渲染函数 ========== function preprocessLuoguSyntax(md) { if (!md) return '';
// 0. 显式处理图片 md = md.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" style="max-width:100%;height:auto;">');
// 1. 处理表格合并 md = convertMergedTables(md);
// 2. cute-table 标记 md = md.replace(/^::cute-table\{tuack\}\n/gm, '<!--tuack-->\n');
// 3. 折叠框等 md = md.replace(/::::(\w+)(?:\[([^\]]*)\])?(?:\{([^}]*)\})?\n([\s\S]*?)\n::::/g, (_, type, title, attrs, content) => { const open = attrs && attrs.includes('open') ? ' open' : ''; // 对 title 进行 HTML 转义 const safeTitle = title ? escapeHtml(title) : ''; return `<details class="luogu-fold luogu-${type}"${open}> <summary>${safeTitle}</summary> ${content} </details>`; } ); md = md.replace(/:::(\w+)(?:\[([^\]]*)\])?(?:\{([^}]*)\})?\n([\s\S]*?)\n:::/g, (_, type, title, attrs, content) => { if (type === 'epigraph') { // 对 cite 内容进行 HTML 转义 const safeTitle = title ? escapeHtml(title) : ''; return `<blockquote class="epigraph"> <p>${content}</p> ${safeTitle ? `<cite>${safeTitle}</cite>` : ''} </blockquote>`; } else if (type === 'align') { if (attrs === 'center') return `<div class="align-center">${content}</div>`; if (attrs === 'right') return `<div class="align-right">${content}</div>`; } else if (['info', 'success', 'warning', 'error'].includes(type)) { const open = attrs && attrs.includes('open') ? ' open' : ''; const safeTitle = title ? escapeHtml(title) : ''; return `<details class="luogu-fold luogu-${type}"${open}> <summary>${safeTitle}</summary> ${content} </details>`; } return _; } );
return md; }
// ---------- 表格合并解析 ---------- function convertMergedTables(md) { const tableRegex = /(^\|.*$[\r\n]*)+/gm; return md.replace(tableRegex, (tableBlock) => { const lines = tableBlock.split(/\r?\n/).filter(line => line.trim().length > 0); if (lines.length < 2) return tableBlock; const hasMerge = lines.some(line => /(?:^|\|)\s*(\^|<)\s*(?:\||$)/.test(line)); if (!hasMerge) return tableBlock;
const parsedRows = lines.map(parseRow); let header = []; let hasHeader = false; let bodyStart = 0; if (parsedRows.length >= 2 && isSeparatorLine(lines[1])) { header = parsedRows[0]; hasHeader = true; bodyStart = 2; } const bodyRows = parsedRows.slice(bodyStart); const allRowLengths = [header.length, ...bodyRows.map(r => r.length)]; const colCount = Math.max(...allRowLengths, 1);
const grid = Array.from({ length: bodyRows.length }, () => new Array(colCount).fill(null)); const occupied = Array.from({ length: bodyRows.length }, () => new Array(colCount).fill(false));
for (let r = 0; r < bodyRows.length; r++) { const cells = bodyRows[r]; let colIdx = 0; for (let c = 0; c < cells.length; c++) { while (colIdx < colCount && occupied[r][colIdx]) colIdx++; if (colIdx >= colCount) break; const val = cells[c].trim();
if (val === '^') { let targetRow = r - 1; while (targetRow >= 0 && grid[targetRow][colIdx] === null) targetRow--; if (targetRow >= 0) { grid[targetRow][colIdx].rowspan++; occupied[r][colIdx] = true; } else { grid[r][colIdx] = { content: '', rowspan: 1, colspan: 1 }; occupied[r][colIdx] = true; } colIdx++; } else if (val === '<') { let leftCol = colIdx - 1; while (leftCol >= 0 && grid[r][leftCol] === null) leftCol--; if (leftCol >= 0) { grid[r][leftCol].colspan++; occupied[r][colIdx] = true; } else { grid[r][colIdx] = { content: '', rowspan: 1, colspan: 1 }; occupied[r][colIdx] = true; } colIdx++; } else { grid[r][colIdx] = { content: val, rowspan: 1, colspan: 1 }; occupied[r][colIdx] = true; colIdx++; } } }
let html = '<table>'; if (hasHeader) { html += '<thead><tr>'; for (let c = 0; c < colCount; c++) { const cell = header[c] ? header[c].trim() : ''; html += `<th>${cell}</th>`; } html += '</tr></thead>'; } html += '<tbody>'; for (let r = 0; r < bodyRows.length; r++) { html += '<tr>'; for (let c = 0; c < colCount; c++) { const cell = grid[r][c]; if (!cell || !occupied[r][c]) continue; const rowspan = cell.rowspan > 1 ? ` rowspan="${cell.rowspan}"` : ''; const colspan = cell.colspan > 1 ? ` colspan="${cell.colspan}"` : ''; html += `<td${rowspan}${colspan}>${cell.content}</td>`; } html += '</tr>'; } html += '</tbody></table>'; return html; }); }
function isSeparatorLine(line) { const trimmed = line.trim(); if (!trimmed.startsWith('|')) return false; const content = trimmed.replace(/^\|/, '').replace(/\|$/, ''); return content.split('|').every(seg => /^[\s\-:]+$/.test(seg) && seg.includes('-')); }
function parseRow(line) { return line.replace(/^\|/, '').replace(/\|$/, '').split('|').map(c => c.trim()); }
function renderMarkdownWithMath(md) { if (!md) return '';
let processed = preprocessLuoguSyntax(md);
// 1. 保护公式 const formulas = []; processed = processed.replace(/(\$\$[\s\S]*?\$\$|\$[^$]+\$)/g, (match) => { const id = formulas.length; formulas.push(match); return `⧙FORMULA${id}⧘`; });
// 2. 保护行内代码 const codes = []; processed = processed.replace(/`([^`]+)`/g, (match) => { const id = codes.length; codes.push(match); return `⧙CODE${id}⧘`; });
// 3. 手动转换粗体(保留内部空格,不压缩) processed = processed.replace(/\*\*([\s\S]*?)\*\*/g, (_, c) => { const t = c.trim(); if (/^\d+(\.\d+)*\.?$/.test(t)) return t; return `<strong>${t}</strong>`; }); processed = processed.replace(/__([\s\S]*?)__/g, (_, c) => { const t = c.trim(); if (/^\d+(\.\d+)*\.?$/.test(t)) return t; return `<strong>${t}</strong>`; });
// 4. 手动转换斜体(保留内部空格) processed = processed.replace(/\*([^*\n]+?)\*/g, (_, c) => `<em>${c.trim()}</em>`); processed = processed.replace(/_([^_\n]+?)_/g, (_, c) => `<em>${c.trim()}</em>`);
// 5. 恢复行内代码 processed = processed.replace(/⧙CODE(\d+)⧘/g, (_, idx) => codes[parseInt(idx)]);
// 6. 将连续空格和制表符替换为 ,避免折叠导致错位 processed = processed.replace(/( {2,}|\t+)/g, (spaces) => ' '.repeat(spaces.length));
// 7. marked 解析块级元素 let html = marked.parse(processed);
// 8. 使用 DOMPurify 清理 HTML,防止 XSS html = DOMPurify.sanitize(html);
// 9. 恢复公式并渲染 html = html.replace(/⧙FORMULA(\d+)⧘/g, (_, idx) => { const formula = formulas[parseInt(idx)]; const isDisplay = formula.startsWith('$$'); const clean = isDisplay ? formula.slice(2, -2).trim() : formula.slice(1, -1).trim(); try { return katex.renderToString(clean, { displayMode: isDisplay, throwOnError: false }); } catch (e) { console.warn('[Luogu-RER] 公式渲染失败,保留原文', clean, e); return formula; } });
return html; }
function insertContent(md) { if (!md) return; const html = renderMarkdown(md); const html = renderMarkdownWithMath(md); const div = document.createElement('div'); div.innerHTML = html;
// 不再强制设置 text-indent,保持原始格式 // 对包含连续空格的段落保留空格(pre-wrap) div.querySelectorAll('p').forEach(p => { p.style.textIndent = '2em'; if (/\s{2,}/.test(p.textContent)) { p.style.whiteSpace = 'pre-wrap'; } });
// 处理 tuack 表格 const walker = document.createTreeWalker(div, NodeFilter.SHOW_COMMENT); const comments = []; while (walker.nextNode()) comments.push(walker.currentNode); comments.forEach(comment => { if (comment.textContent.trim() === 'tuack') { let next = comment.nextSibling; while (next && next.nodeType === Node.TEXT_NODE && !next.textContent.trim()) { next = next.nextSibling; } if (next && next.nodeName === 'TABLE') { const wrapper = document.createElement('div'); wrapper.className = 'tuack-table'; comment.parentNode.insertBefore(wrapper, comment); wrapper.appendChild(next); comment.remove(); } } });
while (div.firstChild) { problemDiv.appendChild(div); problemDiv.appendChild(div.firstChild); } }
// 添加各部分 appendMarkdown(data.desc); // 插入背景 if (data.background) { insertContent(data.background); }
// 插入题目描述 insertContent(data.desc);
if (data.fmtIn) { problemDiv.appendChild(createH2('【输入格式】')); appendMarkdown(data.fmtIn); insertContent(data.fmtIn); } if (data.fmtOut) { problemDiv.appendChild(createH2('【输出格式】')); appendMarkdown(data.fmtOut); insertContent(data.fmtOut); }
// 样例 data.samples.forEach((s, i) => { problemDiv.appendChild(createH2('【样例 ' + (i+1) + '】')); const inp = document.createElement('p'); inp.textContent = '输入 #' + (i+1);14 行未改动 });
if (data.hint) { problemDiv.appendChild(createH2('【提示与说明】')); appendMarkdown(data.hint); insertContent(data.hint); }
function createH2(text) { const h2 = document.createElement('h2'); h2.textContent = text; h2.style.cssText = 'margin-top:43px;margin-bottom:18px;font-size:26px;font-weight:normal;font-family:KaTeX_Main,SimHei,sans-serif;text-indent:1em'; return h2; }
// 全局样式 applyStyles();
// KaTeX 渲染 console.log('[Luogu-RER] 调用 KaTeX 自动渲染...'); try { renderMathInElement(problemDiv, { delimiters: [ {left: '$$', right: '$$', display: true}, {left: '$', right: '$', display: false}, {left: '\\(', right: '\\)', display: false}, {left: '\\[', right: '\\]', display: true} ], throwOnError: false }); console.log('[Luogu-RER] KaTeX 渲染完成'); } catch (e) { console.error('[Luogu-RER] 渲染出错', e); } }
// Markdown 解析(保护公式) function renderMarkdown(text) { const formulas = []; let protectedText = text.replace(/(\$\$[\s\S]*?\$\$|\$[^$]+\$)/g, (match) => { formulas.push(match); return `%%FORMULA${formulas.length - 1}%%`; });
let html = protectedText;
// 图片 html = html.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" style="max-width:100%;display:block;margin:10px auto;">'); // 行内代码 html = html.replace(/`([^`]+)`/g, '<code style="font-family:Consolas,monospace;background:#f0f0f0;padding:2px 6px;border-radius:3px;">$1</code>'); // 粗体 html = html.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>'); html = html.replace(/__([^_]+)__/g, '<strong>$1</strong>'); // 斜体 html = html.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g, '<em>$1</em>'); html = html.replace(/(?<!_)_([^_]+)_(?!_)/g, '<em>$1</em>'); // 无序列表 html = html.replace(/^[\-\*] (.+)$/gm, '<li>$1</li>'); html = html.replace(/((?:<li>.*<\/li>\s*)+)/g, '<ul>$1</ul>'); // 有序列表 html = html.replace(/^\d+\. (.+)$/gm, '<li>$1</li>'); // 链接 html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank">$1</a>'); // 换行 html = html.replace(/\n/g, '<br>');
// 恢复公式 html = html.replace(/%%FORMULA(\d+)%%/g, (_, idx) => formulas[parseInt(idx)]); return html; }
function applyStyles() { GM_addStyle(` @media (prefers-color-scheme: light) { body { background-color: #e6e6e6; } } @media (prefers-color-scheme: dark) { body { background-color: #333333; } #Problem-element { background: #f5f5f5; } } #Problem-element p { margin: 0.5em 0; text-indent: 2em; } #Problem-element strong { font-family: KaTeX_Main, SimHei, sans-serif; font-weight: bold; } #Problem-element p { margin: 0.5em 0; } /* 不再强制 text-indent */ #Problem-element strong { font-weight: bold; } #Problem-element em { font-style: italic; } #Problem-element h1, #Problem-element h2, #Problem-element h3, #Problem-element h4, #Problem-element h5, #Problem-element h6 { font-weight: normal; font-family: KaTeX_Main, SimHei, sans-serif; } #Problem-element h1 { font-size: 1.8em; margin: 0.8em 0; } #Problem-element h2 { font-size: 1.4em; margin: 0.6em 0; } #Problem-element h3 { font-size: 1.2em; margin: 0.5em 0; } #Problem-element ul, #Problem-element ol { padding-left: 2em; } #Problem-element li { margin: 0.2em 0; } #Problem-element a { color: #3498db; text-decoration: none; } #Problem-element a:hover { text-decoration: underline; } #Problem-element img { max-width: 100%; height: auto; } #Problem-element code { font-family: Consolas, monospace; background: #f0f0f0; padding: 2px 6px; border-radius: 3px; } #Problem-element pre { white-space: pre-wrap; background: #f8f8f8; border: 1px solid #ddd; padding: 10px; font-family: Consolas, monospace; font-size: 18px; } #Problem-element table { border-collapse: collapse; margin: 1em 0; width: auto; table-layout: auto; } #Problem-element th, #Problem-element td { border: 1px solid #ccc; padding: 6px 12px; text-align: center; vertical-align: middle; word-break: break-word; } #Problem-element th { background: #f2f2f2; } #Problem-element ::selection { background-color: #99c1da; mix-blend-mode: multiply; color: inherit; } #Custom-toolbar .tb-btn:hover { background: rgba(255,255,255,0.18) !important; color: white !important; } #Custom-toolbar .tb-submit:hover { background: #2980b9 !important; }
#Problem-element details.luogu-fold { margin: 1em 0; border: 1px solid #e0e0e0; border-radius: 4px; padding: 0.5em 1em; background: #fafafa; } #Problem-element details.luogu-fold[open] { background: #fff; } #Problem-element details.luogu-fold summary { font-weight: bold; cursor: pointer; } #Problem-element details.luogu-info { border-left: 4px solid #3498db; } #Problem-element details.luogu-success { border-left: 4px solid #27ae60; } #Problem-element details.luogu-warning { border-left: 4px solid #f39c12; } #Problem-element details.luogu-error { border-left: 4px solid #e74c3c; }
#Problem-element blockquote.epigraph { margin: 1em 0; padding: 1em; background: #f5f5f5; border-left: 4px solid #ccc; font-style: italic; } #Problem-element blockquote.epigraph cite { display: block; text-align: right; font-style: normal; font-weight: bold; }
#Problem-element .align-center { text-align: center; } #Problem-element .align-right { text-align: right; }
@media (max-width: 768px) { #Custom-toolbar { height: auto !important; padding: 6px 12px !important; } #Custom-toolbar > div:first-child { font-size: 13px !important; width: 100% !important; } .tb-btn { font-size: 12px !important; padding: 4px 8px !important; }6 行未改动 }})();```
*(本文脚本版本:v3.9,最后更新于 2026年7月)**(本文脚本版本:v5.2.5,最后更新于 2026 年 8 月)*
本文使用了大语言模型进行润色。本文使用了大语言模型进行润色,Deepseek 参与了脚本的编写。