// ==UserScript== // @name Codeforces Better! // @namespace https://greasyfork.org/users/747162 // @version 1.71 // @description Codeforces界面汉化、黑暗模式支持、题目翻译、markdown视图、一键复制题目、跳转到洛谷、评论区分页、ClistRating分显示、榜单重新着色、题目页代码编辑器、快捷提交,在线测试运行,自定义样例测试、LSP服务,编辑器自定义代码补全 // @author 北极小狐 // @match *://*.codeforces.com/* // @match *://*.codeforc.es/* // @run-at document-start // @connect www2.deepl.com // @connect www.iflyrec.com // @connect m.youdao.com // @connect api.interpreter.caiyunai.com // @connect translate.google.com // @connect openai.api2d.net // @connect api.openai.com // @connect www.luogu.com.cn // @connect clist.by // @connect greasyfork.org // @connect rextester.com // @connect wandbox.org // @connect staticfile.org // @connect 127.0.0.1 // @connect * // @grant GM_xmlhttpRequest // @grant GM_info // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_addStyle // @grant GM_setClipboard // @grant GM_getResourceText // @icon https://aowuucdn.oss-cn-beijing.aliyuncs.com/codeforces.png // @require https://cdn.staticfile.org/turndown/7.1.2/turndown.min.js // @require https://cdn.staticfile.org/markdown-it/13.0.1/markdown-it.min.js // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.1.1/crypto-js.min.js // @require https://cdn.staticfile.org/chroma-js/2.4.2/chroma.min.js // @require https://cdn.staticfile.org/xterm/3.9.2/xterm.min.js // @require https://cdn.staticfile.org/dexie/3.2.4/dexie.min.js // @resource acwing_cpp_code_completer https://aowuucdn.oss-cn-beijing.aliyuncs.com/acwing_cpp_code_completer-0.0.11.json // @resource wandboxlist https://wandbox.org/api/list.json // @resource xtermcss https://cdn.staticfile.org/xterm/3.9.2/xterm.min.css // @license GPL3 // @compatible Chrome // @compatible Firefox // @compatible Edge // @incompatible safari // @supportURL https://github.com/beijixiaohu/OJBetter/issues // @downloadURL none // ==/UserScript== // 状态与初始化 const getGMValue = (key, defaultValue) => { const value = GM_getValue(key); if (value === undefined || value === "") { GM_setValue(key, defaultValue); return defaultValue; } return value; }; var lastReadAnnounceVer = getGMValue("lastReadAnnounceVer", "0"); var darkMode = getGMValue("darkMode", "follow"); var hostAddress = location.origin; var is_mSite, is_acmsguru, is_oldLatex, is_contest, is_problem, is_completeProblemset, is_problemset_problem, is_problemset, is_cfStandings, is_submitPage; var bottomZh_CN, showLoading, hoverTargetAreaDisplay, expandFoldingblocks, renderPerfOpt, translation, commentTranslationChoice; var ttTree, memoryTranslateHistory, autoTranslation, shortTextLength; var openai_model, openai_key, openai_proxy, openai_header, openai_data, openai_isStream, opneaiConfig; var commentTranslationMode, retransAction, transWaitTime, taskQueue, allowMixTrans, mixedTranslation, replaceSymbol, filterTextWithoutEmphasis; var commentPaging, showJumpToLuogu, loaded; var showClistRating_contest, showClistRating_problem, showClistRating_problemset, RatingHidden, clist_Authorization; var standingsRecolor, problemPageCodeEditor, cppCodeTemplateComplete, CompletConfig; var compilerSelection, editorFontSize, onlineCompilerChoice, isCodeSubmitConfirm; var CF_csrf_token; var monacoLoaderOnload = false, monacoSocket = [], editor, useLSP, OJBetter_Bridge_WorkUri, OJBetter_Bridge_SocketUrl; var monacoEditor_language = [], monacoEditor_position, monacoEditor_position_init = false; function init() { const { hostname, href } = window.location; is_mSite = /^m[0-9]/.test(hostname); is_oldLatex = $('.tex-span').length; is_acmsguru = href.includes("acmsguru") && href.includes('/problem/'); is_contest = /\/contest\/[\d\/\s]+$/.test(href) && !href.includes('/problem/'); is_problem = href.includes('/problem/'); is_completeProblemset = /problems\/?$/.test(href); is_problemset_problem = href.includes('/problemset/') && href.includes('/problem/'); is_problemset = href.includes('/problemset') && !href.includes('/problem/'); is_submitPage = href.includes('/submit'); is_cfStandings = href.includes('/standings') && $('.standings tr:first th:nth-child(n+5)') .map(function () { return $(this).find('span').text(); }) .get() .every(score => /^[0-9]+$/.test(score)); bottomZh_CN = getGMValue("bottomZh_CN", true); showLoading = getGMValue("showLoading", true); hoverTargetAreaDisplay = getGMValue("hoverTargetAreaDisplay", false); expandFoldingblocks = getGMValue("expandFoldingblocks", true); renderPerfOpt = getGMValue("renderPerfOpt", false); commentPaging = getGMValue("commentPaging", true); showJumpToLuogu = getGMValue("showJumpToLuogu", true); standingsRecolor = getGMValue("standingsRecolor", true); loaded = getGMValue("loaded", false); translation = getGMValue("translation", "deepl"); commentTranslationMode = getGMValue("commentTranslationMode", "0"); commentTranslationChoice = getGMValue("commentTranslationChoice", "0"); memoryTranslateHistory = getGMValue("memoryTranslateHistory", true); autoTranslation = getGMValue("autoTranslation", false); shortTextLength = getGMValue("shortTextLength", "2000"); retransAction = getGMValue("retransAction", "0"); transWaitTime = getGMValue("transWaitTime", "200"); allowMixTrans = getGMValue("allowMixTrans", true); mixedTranslation = getGMValue("mixedTranslation", ['deepl', 'iflyrec', 'youdao', 'caiyun']); taskQueue = new TaskQueue(); replaceSymbol = getGMValue("replaceSymbol", "2"); filterTextWithoutEmphasis = getGMValue("filterTextWithoutEmphasis", false); showClistRating_contest = getGMValue("showClistRating_contest", false); showClistRating_problem = getGMValue("showClistRating_problem", false); showClistRating_problemset = getGMValue("showClistRating_problemset", false); RatingHidden = getGMValue("RatingHidden", false); clist_Authorization = getGMValue("clist_Authorization", ""); //openai openai_isStream = getGMValue("openai_isStream", true); opneaiConfig = getGMValue("chatgpt-config", { "choice": -1, "configurations": [] }); if (opneaiConfig.choice !== -1 && opneaiConfig.configurations.length !== 0) { const configAtIndex = opneaiConfig.configurations[opneaiConfig.choice]; if (configAtIndex == undefined) { let existingConfig = GM_getValue('chatgpt-config'); existingConfig.choice = 0; GM_setValue('chatgpt-config', existingConfig); location.reload(); } openai_model = configAtIndex.model; openai_key = configAtIndex.key; openai_proxy = configAtIndex.proxy; openai_header = configAtIndex._header ? configAtIndex._header.split("\n").map(header => { const [key, value] = header.split(":"); return { [key.trim()]: value.trim() }; }) : []; openai_data = configAtIndex._data ? configAtIndex._data.split("\n").map(header => { const [key, value] = header.split(":"); return { [key.trim()]: value.trim() }; }) : []; } // 编辑器 if (!is_mSite) CF_csrf_token = Codeforces.getCsrfToken(); else CF_csrf_token = ""; compilerSelection = getGMValue("compilerSelection", "61"); editorFontSize = getGMValue("editorFontSize", "15"); problemPageCodeEditor = getGMValue("problemPageCodeEditor", true); cppCodeTemplateComplete = getGMValue("cppCodeTemplateComplete", true); onlineCompilerChoice = getGMValue("onlineCompilerChoice", "official"); isCodeSubmitConfirm = getGMValue("isCodeSubmitConfirm", true); //自定义补全 CompletConfig = getGMValue("Complet_config", { "choice": -1, "configurations": [] }); /** * 加载monaco编辑器资源 */ useLSP = getGMValue("useLSP", false); monacoEditor_position = getGMValue("monacoEditor_position", "initial"); OJBetter_Bridge_WorkUri = getGMValue("OJBetter_Bridge_WorkUri", "C:/OJBetter_Bridge"); OJBetter_Bridge_SocketUrl = getGMValue("OJBetter_Bridge_SocketUrl", "ws://127.0.0.1:2323/"); let monacoLoader = document.createElement("script"); monacoLoader.src = "https://cdn.staticfile.org/monaco-editor/0.44.0/min/vs/loader.min.js"; document.head.prepend(monacoLoader); monacoLoader.onload = () => { require.config({ paths: { vs: "https://cdn.staticfile.org/monaco-editor/0.44.0/min/vs" }, "vs/nls": { availableLanguages: { "*": "zh-cn" } }, }); require(["vs/editor/editor.main"], () => { monacoLoaderOnload = true; }); } } // 公告 async function showAnnounce() { if (lastReadAnnounceVer < GM_info.script.version) { const title = "已更新至1.71" const content = ` #### 更新日志 - 更新 clist rating 的API为v4,调整题目页的数据获取方式为通过API获取,感谢 @wrkwrk 的建议 - 添加 ChatGPT 翻译 “流式传输” 选项,默认开启 - 修复 Google 翻译结果为空的问题 感谢 @shicxin 的反馈 - 添加一个配置开关 "代码提交是否二次确认" ,默认开启 感谢 @Rikkual 的建议 - 在完整题目集页中添加小区域的按钮 - 修复完整题目集页右键打印时不显示翻译结果的问题 感谢 @zfs732 的反馈 #### 作者有话说 对于功能故障(比如接口问题),一旦收到反馈,作者会立即进行修复并将更改提交至 [Github仓库](https://github.com/beijixiaohu/OJBetter/commits/main/) 然而,请注意,这些修复**不会**立即以更新的形式发布。因此,如果你发现了一个可能的功能故障,请先前往 Github 查看是否已经修复。 除非遇到严重问题,否则作者倾向于不发布零星的更新,而是将修改积累起来,待到合适的时机一并发布。 `; const ok = await createDialog(title, content, ["我知道了", null], undefined, true); //跳过折叠块确认 if (ok) { GM_setValue('lastReadAnnounceVer', GM_info.script.version); } } }; // 显示警告消息 function ShowAlertMessage() { if (is_oldLatex) { let newElement = $("
").addClass("alert alert-warning ojbetter-alert") .html(`${OJBetterName} —— 注意:当前页面存在未保存原 LaTeX 代码的 LaTeX 公式(这通常是一道古老的题目),这导致脚本无法将其还原回 LaTeX,因此当前页面部分功能不适用。除非你现在需要翻译超长篇的博客或者题目,否则请前往设置切换为普通模式
`) .css({ "margin": "1em", "text-align": "center", "position": "relative" }); $(".menu-box:first").next().after(newElement); } if (commentTranslationMode == "2") { let newElement = $("").addClass("alert alert-error CFBetter_alert") .html(`${OJBetterName} —— 注意!当前为选段翻译模式,只会翻译目标区域内已选中的部分,点击段落以选中(橙色框)如果你现在不需要翻译超长篇的博客或者题目,建议你请前往设置切换为普通模式
`) .css({ "margin": "1em", "text-align": "center", "position": "relative" }); $(".menu-box:first").next().after(newElement); } if (is_submitPage && problemPageCodeEditor) { let newElement = $("").addClass("alert alert-warning CFBetter_alert") .html(`${OJBetterName} —— 你已开启 “题目页添加编辑器” 选项,在问题页下方即可快速提交哦${findHelpText2}
`) .css({ "margin": "1em", "text-align": "center", "position": "relative" }); $(".menu-box:first").next().after(newElement); } } // 常量 const OJBetterName = 'Codeforces Better!'; const findHelpText1 = '\n\n如果无法解决,请前往 https://greasyfork.org/zh-CN/scripts/465777/feedback 或者 https://github.com/beijixiaohu/OJBetter/issues 寻求帮助\n\n'; const findHelpText2 = '如遇问题,请前往 https://greasyfork.org/zh-CN/scripts/465777/feedback 或者 https://github.com/beijixiaohu/OJBetter/issues 反馈'; const helpCircleHTML = ''; const unfoldIcon = ``; const putawayIcon = ``; const closeIcon = ``; const copyIcon = ``; const copyedIcon = ``; const translateIcon = ``; const clistIcon = ``; const darkenPageStyle = `body::before { content: ""; display: block; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4); z-index: 200; }`; const darkenPageStyle2 = `body::before { content: ""; display: block; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4); z-index: 300; }`; // 连接数据库 var CFBetterDB; function initDB() { CFBetterDB = new Dexie('CFBetterDB'); CFBetterDB.version(2).stores({ samplesData: `&url`, editorCode: `&url`, translateData: `&url` }); } // 切换系统黑暗监听 const mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)'); const changeEventListeners = []; function handleColorSchemeChange(event) { event.matches ? $('html').attr('data-theme', 'dark') : $('html').attr('data-theme', 'light'); if (!event.matches) { var originalColor = $(this).data("original-color"); $(this).css("background-color", originalColor); if (editor) { monaco.editor.setTheme('vs'); } } else { if (editor) { monaco.editor.setTheme('vs-dark'); } } } // 黑暗模式 (function setDark() { // 初始化 function setDarkTheme() { const htmlElement = document.querySelector('html'); if (htmlElement) { htmlElement.setAttribute('data-theme', 'dark'); } else { setTimeout(setDarkTheme, 100); } } if (darkMode == "dark") { setDarkTheme(); } else if (darkMode == "follow") { // 添加事件监听器 changeEventListeners.push(handleColorSchemeChange); mediaQueryList.addEventListener('change', handleColorSchemeChange); if (window.matchMedia('(prefers-color-scheme: dark)').matches) setDarkTheme(); } GM_addStyle(` /* 黑暗支持 */ html[data-theme=dark]:root { color-scheme: light dark; } /* 文字颜色1 */ html[data-theme=dark] .title,html[data-theme=dark] .problem-statement, html[data-theme=dark] .ttypography, html[data-theme=dark] .roundbox, html[data-theme=dark] .info, html[data-theme=dark] .ttypography .bordertable, html[data-theme=dark] .ttypography .bordertable thead th, html[data-theme=dark] .ttypography h1, html[data-theme=dark] .ttypography h2, html[data-theme=dark] .ttypography h3, html[data-theme=dark] .ttypography h4, html[data-theme=dark] .ttypography h5, html[data-theme=dark] .ttypography h6 html[data-theme=dark] .datatable table, html[data-theme=dark] .problem-statement .sample-tests pre, html[data-theme=dark] .alert-success, html[data-theme=dark] .alert-info, html[data-theme=dark] .alert-error, html[data-theme=dark] .alert-warning, html[data-theme=dark] .markItUpEditor, html[data-theme=dark] #pageContent, html[data-theme=dark] .ace-chrome .ace_gutter, html[data-theme=dark] .translate-problem-statement, html[data-theme=dark] .setting-name, html[data-theme=dark] .CFBetter_setting_menu, html[data-theme=dark] .help_tip .tip_text, html[data-theme=dark] textarea, html[data-theme=dark] .user-black, html[data-theme=dark] .comments label.show-archived, html[data-theme=dark] .comments label.show-archived *, html[data-theme=dark] table, html[data-theme=dark] #items-per-page, html[data-theme=dark] #pagBar, html[data-theme=dark] .CFBetter_setting_sidebar li a:link, html[data-theme=dark] .popup .content{ color: #a0adb9 !important; } html[data-theme=dark] h1 a, html[data-theme=dark] h2 a, html[data-theme=dark] h3 a, html[data-theme=dark] h4 a{ color: #adbac7; } /* 文字颜色2 */ html[data-theme=dark] .contest-state-phase, html[data-theme=dark] .legendary-user-first-letter, html[data-theme=dark] .lang-chooser, html[data-theme=dark] .second-level-menu-list li a, html[data-theme=dark] #footer, html[data-theme=dark] .ttypography .tt, html[data-theme=dark] select, html[data-theme=dark] .roundbox .caption, html[data-theme=dark] .topic .title *, html[data-theme=dark] .user-admin, html[data-theme=dark] button.html2mdButton:hover, html[data-theme=dark] .CFBetter_modal button, html[data-theme=dark] #CFBetter_statusBar, html[data-theme=dark] #RunTestButton, html[data-theme=dark] #programTypeId, html[data-theme=dark] #addCustomTest, html[data-theme=dark] #customTestBlock{ color: #9099a3 !important; } /* 文字颜色3 */ html[data-theme=dark] button.html2mdButton, html[data-theme=dark] #program-source-text-copy{ color: #6385a6; } html[data-theme=dark] input{ color: #6385a6 !important; } /* 文字颜色4 */ html[data-theme=dark] .ttypography .MathJax, html[data-theme=dark] .MathJax span{ color: #cbd6e2 !important; } /* 链接颜色 */ html[data-theme=dark] a:link { color: #3989c9; } html[data-theme=dark] a:visited { color: #8590a6; } html[data-theme=dark] .menu-box a, html[data-theme=dark] .sidebox th a{ color: #9099a3 !important; } /* 按钮 */ html[data-theme=dark] .second-level-menu-list li.backLava { border-radius: 6px; overflow: hidden; filter: invert(1) hue-rotate(.5turn); } html[data-theme=dark] input:hover{ background-color: #22272e !important; } /* 背景层次1 */ html[data-theme=dark] body, html[data-theme=dark] .ttypography .bordertable thead th, html[data-theme=dark] .datatable table, html[data-theme=dark] .datatable .dark, html[data-theme=dark] li#add_button, html[data-theme=dark] .problem-statement .sample-tests pre, html[data-theme=dark] .markItUpEditor, html[data-theme=dark] .SumoSelect>.CaptionCont, html[data-theme=dark] .SumoSelect>.optWrapper, html[data-theme=dark] .SumoSelect>.optWrapper.multiple>.options li.opt span i, html[data-theme=dark] .ace_scroller, html[data-theme=dark] .CFBetter_setting_menu, html[data-theme=dark] .help_tip .tip_text, html[data-theme=dark] li#add_button:hover, html[data-theme=dark] textarea, html[data-theme=dark] .state, html[data-theme=dark] .ace-chrome .ace_gutter-active-line, html[data-theme=dark] .sidebar-menu ul li:hover, html[data-theme=dark] .sidebar-menu ul li.active, html[data-theme=dark] label.config_bar_ul_li_text:hover, html[data-theme=dark] button.html2mdButton:hover, html[data-theme=dark] .CFBetter_setting_sidebar li a.active, html[data-theme=dark] .CFBetter_setting_sidebar li, html[data-theme=dark] .CFBetter_setting_menu::-webkit-scrollbar-track, html[data-theme=dark] .CFBetter_setting_content::-webkit-scrollbar-track, html[data-theme=dark] .CFBetter_modal, html[data-theme=dark] .CFBetter_modal button:hover, html[data-theme=dark] .popup .content, html[data-theme=dark] .file.input-view .text, html[data-theme=dark] .file.output-view .text, html[data-theme=dark] .file.answer-view .text, html[data-theme=dark] .file.checker-comment-view .text, html[data-theme=dark] .config_bar_list, html[data-theme=dark] #CFBetter_SubmitForm .topDiv div#lspStateDiv, html[data-theme=dark] #LSPLog, html[data-theme=dark] .CFBetter_setting_menu .CFBetter_checkboxs, html[data-theme=dark] .CFBetter_setting_menu .CFBetter_checkboxs input[type="checkbox"]::before{ background-color: #22272e !important; } /* 背景层次2 */ html[data-theme=dark] .roundbox, html[data-theme=dark] .roundbox .dark, html[data-theme=dark] .bottom-links, html[data-theme=dark] button.html2mdButton, html[data-theme=dark] .spoiler-content, html[data-theme=dark] input, html[data-theme=dark] .problem-statement .test-example-line-even, html[data-theme=dark] .highlight-blue, html[data-theme=dark] .ttypography .tt, html[data-theme=dark] select, html[data-theme=dark] .alert-success, html[data-theme=dark] .alert-info, html[data-theme=dark] .alert-error, html[data-theme=dark] .alert-warning, html[data-theme=dark] .SumoSelect>.optWrapper>.options li.opt:hover, html[data-theme=dark] .input-output-copier:hover, html[data-theme=dark] .translate-problem-statement-panel, html[data-theme=dark] .aceEditorTd, html[data-theme=dark] .ace-chrome .ace_gutter, html[data-theme=dark] .translate-problem-statement, html[data-theme=dark] .datatable, html[data-theme=dark] .CFBetter_setting_list, html[data-theme=dark] .CFBetter_setting_menu hr, html[data-theme=dark] .highlighted-row td, html[data-theme=dark] .highlighted-row th, html[data-theme=dark] .pagination span.active, html[data-theme=dark] .CFBetter_setting_sidebar li a, html[data-theme=dark] .CFBetter_setting_menu::-webkit-scrollbar-thumb, html[data-theme=dark] .CFBetter_setting_content::-webkit-scrollbar-thumb, html[data-theme=dark] .CFBetter_modal button, html[data-theme=dark] .test-for-popup pre, html[data-theme=dark] .popup .content pre, html[data-theme=dark] .popup .content pre code, html[data-theme=dark] ul.config_bar_ul::-webkit-scrollbar-thumb, html[data-theme=dark] #CFBetter_statusBar, html[data-theme=dark] #RunTestButton, html[data-theme=dark] #programTypeId, html[data-theme=dark] .sampleDiv, html[data-theme=dark] #addCustomTest, html[data-theme=dark] #LSPLog li:nth-child(odd), html[data-theme=dark] .CFBetter_setting_menu .CFBetter_checkboxs input[type="checkbox"]:checked::before{ background-color: #2d333b !important; } /* 实线边框颜色-圆角 */ html[data-theme=dark] .roundbox, html[data-theme=dark] .roundbox .rtable td, html[data-theme=dark] button.html2mdButton, html[data-theme=dark] .sidebar-menu ul li, html[data-theme=dark] input, html[data-theme=dark] .ttypography .tt, html[data-theme=dark] #items-per-page, html[data-theme=dark] .datatable td, html[data-theme=dark] .datatable th, html[data-theme=dark] .alert-success, html[data-theme=dark] .alert-info, html[data-theme=dark] .alert-error, html[data-theme=dark] .alert-warning, html[data-theme=dark] .translate-problem-statement, html[data-theme=dark] textarea, html[data-theme=dark] .input-output-copier{ border: 1px solid #424b56 !important; border-radius: 2px; } /* 实线边框颜色-无圆角 */ html[data-theme=dark] .CFBetter_setting_list, html[data-theme=dark] .config_bar_list, html[data-theme=dark] label.config_bar_ul_li_text, html[data-theme=dark] .problem-statement .sample-tests .input, html[data-theme=dark] .problem-statement .sample-tests .output, html[data-theme=dark] .pagination span.active, html[data-theme=dark] .CFBetter_setting_sidebar li, html[data-theme=dark] .CFBetter_setting_menu select, html[data-theme=dark] .translate-problem-statement-panel, html[data-theme=dark] .CFBetter_modal button, html[data-theme=dark] .test-for-popup pre, html[data-theme=dark] #CFBetter_editor, html[data-theme=dark] #CFBetter_statusBar, html[data-theme=dark] #RunTestButton, html[data-theme=dark] #programTypeId, html[data-theme=dark] #customTestBlock, html[data-theme=dark] #addCustomTest, html[data-theme=dark] #CFBetter_SubmitForm .topDiv div#lspStateDiv, html[data-theme=dark] #CompilerSetting select, html[data-theme=dark] #CompilerSetting textarea, html[data-theme=dark] #CompilerBox, html[data-theme=dark] .CFBetter_setting_menu .CFBetter_checkboxs{ border: 1px solid #424b56 !important; } html[data-theme=dark] .roundbox .titled, html[data-theme=dark] .roundbox .rtable th { border-bottom: 1px solid #424b56 !important; } html[data-theme=dark] .roundbox .bottom-links, html[data-theme=dark] #footer{ border-top: 1px solid #424b56 !important; } html[data-theme=dark] .topic .content { border-left: 4px solid #424b56 !important; } html[data-theme=dark] .CFBetter_setting_sidebar { border-right: 1px solid #424b56 !important; } html[data-theme=dark] hr { border-color: #424b56 !important; } /* 虚线边框颜色 */ html[data-theme=dark] .comment-table, html[data-theme=dark] li#add_button, html[data-theme=dark] .CFBetter_setting_menu_label_text{ border: 1px dashed #424b56 !important; } html[data-theme=dark] li#add_button:hover{ border: 1px dashed #03A9F4 !important; background-color: #2d333b !important; color: #03A9F4 !important; } /* 无边框 */ html[data-theme=dark] .html2md-panel.input-output-copier, html[data-theme=dark] .translateDiv.input-output-copier { border: none !important; } /* 无背景 */ html[data-theme=dark] .html2md-panel.input-output-copier:hover{ background-color: #ffffff00 !important; } /* focus-visible */ html[data-theme=dark] input:focus-visible, html[data-theme=dark] textarea, html[data-theme=dark] select{ border-width: 1.5px !important; outline: none; } /* 图片-亮度 */ html[data-theme=dark] img, html[data-theme=dark] #facebox .popup a{ opacity: .75; } /* 反转 */ html[data-theme=dark] .SumoSelect>.CaptionCont>label>i, html[data-theme=dark] .delete-resource-link, html[data-theme=dark] #program-source-text, html[data-theme=dark] .spoiler-content pre, html[data-theme=dark] .popup .content pre code{ filter: invert(1) hue-rotate(.5turn); } /* 区域遮罩 */ html[data-theme=dark] .overlay::before { background: repeating-linear-gradient(135deg, #49525f6e, #49525f6e 30px, #49525f29 0px, #49525f29 55px); color: #9099a3; text-shadow: 0px 0px 2px #000000; } /* 阴影 */ html[data-theme=dark] .translate-problem-statement-panel, html[data-theme=dark] .translate-problem-statement{ box-shadow: 0px 0px 0.5px 0.5px #30353b; } /* 其他样式 */ html[data-theme=dark] .rated-user{ display: initial; } html[data-theme=dark] .datatable .ilt, html[data-theme=dark] .datatable .irt, html[data-theme=dark] .datatable .ilb, html[data-theme=dark] .datatable .irb, html[data-theme=dark] .datatable .lt, html[data-theme=dark] .datatable .rt, html[data-theme=dark] .datatable .lb, html[data-theme=dark] .datatable .rb{ background: none; } html[data-theme=dark] .problems .accepted-problem td.id{ border-left: 6px solid #47837d !important; } html[data-theme=dark] .problems .rejected-problem td.id{ border-left: 6px solid #ef9a9a !important; } html[data-theme=dark] .problems .accepted-problem td.act { background-color: #47837d !important; border-radius: 0px; } html[data-theme=dark] .problems .rejected-problem td.act{ background-color: #ef9a9a !important; border-radius: 0px; } html[data-theme=dark] .CFBetter_setting_menu, html[data-theme=dark] .CFBetter_modal{ box-shadow: 0px 0px 0px 4px #2d333b; border: 1px solid #2d333b; } html[data-theme=dark] .collapsible-topic.collapsed .content .collapsible-topic-options:before{ background-image: linear-gradient(#22272e00, #22272e); } html[data-theme=dark] .alert{ text-shadow: none; } html[data-theme=dark] input[type="radio"]:checked+.CFBetter_setting_menu_label_text { color: #a0adb9 !important; border: 1px solid #326154 !important; } /* 评测状态文字颜色 */ html[data-theme=dark] .verdict-accepted, html[data-theme=dark] .verdict-accepted-challenged, html[data-theme=dark] .verdict-successful-challenge{ color: #0a0 !important; } html[data-theme=dark] .verdict-failed, html[data-theme=dark] .verdict-challenged{ color: red !important; } html[data-theme=dark] .verdict-rejected, html[data-theme=dark] .verdict-unsuccessful-challenge{ color: #673ab7 !important; } html[data-theme=dark] .verdict-waiting { color: gray !important; } /* 样例hover样式 */ html[data-theme=dark] .test-example-line-odd:hover, html[data-theme=dark] .test-example-line-odd.darkhighlight { background-color: #455a64; } `); })() /** * 黑暗模式额外的处理事件 */ function darkModeStyleAdjustment() { $(".test-example-line").off("mouseenter mouseleave"); // 移除上面原本的事件 $('.test-example-line-odd').hover( function () { $(this).addClass('darkhighlight'); $(this).prevUntil(':not(.test-example-line-odd)').addClass('darkhighlight'); $(this).nextUntil(':not(.test-example-line-odd)').addClass('darkhighlight'); }, function () { $(this).removeClass('darkhighlight'); $(this).prevUntil(':not(.test-example-line-odd)').removeClass('darkhighlight'); $(this).nextUntil(':not(.test-example-line-odd)').removeClass('darkhighlight'); } ); } // 样式 GM_addStyle(` html { scroll-behavior: smooth; } :root { --vp-font-family-base: "Chinese Quotes", "Inter var", "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; } span.mdViewContent { white-space: pre-wrap; } /*翻译区域提示*/ .overlay::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: repeating-linear-gradient(135deg, #97e7cacc, #97e7cacc 30px, #e9fbf1cc 0px, #e9fbf1cc 55px); z-index: 100; } .overlay::after { content: '目标区域'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #00695C; font-size: 16px; font-weight: bold; z-index: 100; } /*翻译div*/ /* 特殊处理,加上input-output-copier类, 让convertStatementToText方法忽略该元素 */ .translateDiv.input-output-copier { font-size: initial; float: initial; color: initial; cursor: initial; border: none; padding: 0px; margin: 0px; line-height: initial; text-transform: none; } .translateDiv { box-shadow: 0px 0px 0.5px 0.5px #defdf378; } .translate-problem-statement { justify-items: start; letter-spacing: 1.8px; color: #059669; background-color: #f9f9fa; border: 1px solid #c5ebdf; border-radius: 0rem 0rem 0.3rem 0.3rem; padding: 5px; margin: -5px 0px 6px 0px; width: 100%; box-sizing: border-box; font-size: 13px; } .translate-problem-statement.error_translate { color: red; border-color: red; } .translate-problem-statement a, .translate-problem-statement a:link { color: #10b981; font-weight: 600; background: 0 0; text-decoration: none; } .translate-problem-statement ol, .translate-problem-statement ul { display: grid; margin-inline-start: 0.8em; margin-block-start: 0em; margin: 0.5em 0 0 3em; } .translate-problem-statement li { display: list-item; height: auto; word-wrap: break-word; } .translate-problem-statement ol li { list-style-type: auto; } .translate-problem-statement ul li { list-style-type: disc; } .translate-problem-statement img { max-width: 100.0%; max-height: 100.0%; } .ttypography .translate-problem-statement .MathJax { color: #059669!important; } .translate-problem-statement span.math { margin: 0px 2.5px !important; } .translate-problem-statement a:hover { background-color: #800; color: #fff; text-decoration: none; } .translate-problem-statement-panel{ display: flex; justify-content: space-between; background-color: #f9f9fa; border: 1px solid #c5ebdf; border-radius: 0.3rem; margin: 4px 0px; } .html2md-panel { display: flex; justify-content: flex-end; align-items: center; } .html2md-panel a { text-decoration: none; } .html2mdButton { display: flex; align-items: center; cursor: pointer; background-color: #ffffff; color: #606266; height: 22px; width: auto; font-size: 13px; border-radius: 0.3rem; padding: 1px 5px; margin: 5px !important; border: 1px solid #dcdfe6; } .html2mdButton[disabled] { cursor: not-allowed !important; background-color: rgb(255, 255, 255) !important; color: rgb(168, 171, 178) !important; border: 1px solid rgb(228, 231, 237) !important; } .html2mdButton:hover { color: #409eff; border-color: #409eff; background-color: #f1f8ff; z-index: 100; } button.html2mdButton.copied { background-color: #f0f9eb; color: #67c23e; border: 1px solid #b3e19d; } button.html2mdButton.mdViewed { background-color: #fdf6ec; color: #e6a23c; border: 1px solid #f3d19e; } button.html2mdButton.error { background-color: #fef0f0; color: #f56c6c; border: 1px solid #fab6b6; } button.translated { background-color: #f0f9eb; color: #67c23e; border: 1px solid #b3e19d; } button.html2mdButton.reTranslation { background-color: #f4f4f5; color: #909399; border: 1px solid #c8c9cc; } .topText { display: flex; margin-left: 5px; color: #9e9e9e; font-size: 13px; align-items: center; } .borderlessButton{ display: flex; align-items: center; margin: 2.5px 7px; fill: #9E9E9E; } .borderlessButton:hover{ cursor: pointer; fill: #059669; } .translate-problem-statement table { border: 1px #ccc solid !important; margin: 1.5em 0 !important; color: #059669 !important; } .translate-problem-statement table thead th { border: 1px #ccc solid !important; color: #059669 !important; } .translate-problem-statement table td { border-right: 1px solid #ccc; border-top: 1px solid #ccc; padding: 0.7143em 0.5em; } .translate-problem-statement table th { padding: 0.7143em 0.5em; } .translate-problem-statement p:not(:first-child) { margin: 1.5em 0 0; } .translate-problem-statement p { line-height: 20px !important; } .problem-statement p:last-child { margin-bottom: 0px !important; } /*特殊处理, 加上input-output-copier类, 让convertStatementToText方法忽略该元素*/ .html2md-panel.input-output-copier { font-size: initial; float: initial; color: initial; cursor: initial; border: none; padding: 0px; margin: 0px; line-height: initial; text-transform: none; } .html2md-panel.input-output-copier:hover { background-color: #ffffff00; } /*设置面板*/ header .enter-or-register-box, header .languages { position: absolute; right: 170px; } button.html2mdButton.CFBetter_setting { float: right; height: 30px; background: #60a5fa; color: white; margin: 10px; border: 1px solid #60a5fa; } button.html2mdButton.CFBetter_setting.open { background-color: #e6e6e6; color: #727378; cursor: not-allowed; } .CFBetter_setting_menu { z-index: 200; box-shadow: 0px 0px 0px 4px #ffffff; position: fixed; top: 50%; left: 50%; width: 500px; min-height: 600px; transform: translate(-50%, -50%); border-radius: 6px; background-color: #f0f4f9; border-collapse: collapse; border: 1px solid #ffffff; color: #697e91; font-family: var(--vp-font-family-base); padding: 10px 20px 20px 10px; box-sizing: content-box; } .CFBetter_setting_menu h3 { margin-top: 10px; } .CFBetter_setting_menu h4 { margin: 15px 0px 10px 0px; } .CFBetter_setting_menu h4,.CFBetter_setting_menu h5 { font-weight: 600; } .CFBetter_setting_menu hr { border: none; height: 1px; background-color: #ccc; margin: 10px 0; } .CFBetter_setting_menu .badge { border-radius: 4px; border: 1px solid #009688; color: #009688; font-size: 12px; padding: 0.5px 4px; margin-left: 5px; margin-right: auto; } /* 页面切换 */ .settings-page { display: none; } .settings-page.active { display: block; } .CFBetter_setting_container { display: flex; } .CFBetter_setting_sidebar { width: 110px; padding: 6px 10px 6px 6px; margin: 20px 0px; border-right: 1px solid #d4d8e9; } .CFBetter_setting_content { flex-grow: 1; width: 360px; margin: 20px 0px 0px 20px; padding-right: 10px; max-height: 580px; overflow-y: auto; box-sizing: border-box; } .CFBetter_setting_sidebar h3 { margin-top: 0; } .CFBetter_setting_sidebar hr { margin-top: 10px; margin-bottom: 10px; border: none; border-top: 1px solid #DADCE0; } .CFBetter_setting_sidebar ul { list-style-type: none; margin: 0; padding: 0; } .CFBetter_setting_sidebar li { margin: 5px 0px; background-color: #ffffff; border: 1px solid #d4d8e9; border-radius: 4px; font-size: 16px; } .CFBetter_setting_sidebar li a { text-decoration: none; display: flex; width: 100%; color: gray; letter-spacing: 2px; padding: 7px; border-radius: 4px; align-items: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .CFBetter_setting_sidebar li a.active { background-color: #eceff1c7; } /* 下拉选择框 */ .CFBetter_setting_menu select { appearance: none; padding: 5px 10px; margin: -5px 0px; border-radius: 6px; border-style: solid; border: 1px solid #ced4da; color: #009688; font-size: 15px; } .CFBetter_setting_menu select:focus-visible { outline: none; } /* 数值输入框 */ .CFBetter_setting_menu input[type="number"] { width: 40px; color: #009688; font-size: 15px; appearance: none; padding: 5px 10px; margin: -5px 3px; border-radius: 6px; border-style: solid; border: 1px solid #ced4da; } .CFBetter_setting_menu input[type="number"]:focus-visible { outline: none; } .CFBetter_setting_menu input[type="number"]::-webkit-inner-spin-button, .CFBetter_setting_menu input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; } /*设置面板-滚动条*/ .CFBetter_setting_menu::-webkit-scrollbar, .CFBetter_setting_content::-webkit-scrollbar { width: 5px; height: 7px; background-color: #aaa; } .CFBetter_setting_menu::-webkit-scrollbar-thumb, .CFBetter_setting_content::-webkit-scrollbar-thumb { background-clip: padding-box; background-color: #d7d9e4; } .CFBetter_setting_menu::-webkit-scrollbar-track, .CFBetter_setting_content::-webkit-scrollbar-track { background-color: #f1f1f1; } /*设置面板-关闭按钮*/ .CFBetter_setting_menu .tool-box { position: absolute; width: 20px; height: 20px; top: 3px; right: 3px; } .CFBetter_setting_menu .btn-close { cursor: pointer; width: 20px; height: 20px; border-radius: 50%; border: none; margin: 0px; padding: 0px; background-color: #ff000080; transition: .15s ease all; box-sizing: border-box; text-align: center; color: transparent; font-size: 17px; } .CFBetter_setting_menu .btn-close:hover { color: #ffffff; background-color: #ff0000cc; box-shadow: 0 5px 5px 0 #00000026; } .CFBetter_setting_menu .btn-close:active { color: #ffffffde; background-color: #ff000080; } /*设置面板-checkbox*/ .CFBetter_setting_menu input[type=checkbox]:focus { outline: 0px; } .CFBetter_setting_menu .CFBetter_setting_list input[type="checkbox"] { margin: 0px; appearance: none; -webkit-appearance: none; width: 40px; height: 20px; border: 1.5px solid #D7CCC8; padding: 0px !important; border-radius: 20px; background: #efebe978; position: relative; box-sizing: border-box; } .CFBetter_setting_menu .CFBetter_setting_list input[type="checkbox"]::before { content: ""; width: 17px; height: 17px; background: #D7CCC8; border: 1.5px solid #BCAAA4; border-radius: 50%; position: absolute; top: 0; left: 0; transform: translate(2%, 2%); transition: all 0.3s ease-in-out; box-sizing: border-box; } .CFBetter_setting_menu .CFBetter_setting_list input[type="checkbox"]::after { content: url("data:image/svg+xml,%3Csvg xmlns='://www.w3.org/2000/svg' width='23' height='23' viewBox='0 0 23 23' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M6.55021 5.84315L17.1568 16.4498L16.4497 17.1569L5.84311 6.55026L6.55021 5.84315Z' fill='%23EA0707' fill-opacity='0.89'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M17.1567 6.55021L6.55012 17.1568L5.84302 16.4497L16.4496 5.84311L17.1567 6.55021Z' fill='%23EA0707' fill-opacity='0.89'/%3E%3C/svg%3E"); position: absolute; top: 0; left: 24px; } .CFBetter_setting_menu .CFBetter_setting_list input[type="checkbox"]:checked { border: 1.5px solid #C5CAE9; background: #E8EAF6; } .CFBetter_setting_menu .CFBetter_setting_list input[type="checkbox"]:checked::before { background: #C5CAE9; border: 1.5px solid #7986CB; transform: translate(122%, 2%); transition: all 0.3s ease-in-out; } .CFBetter_setting_menu .CFBetter_setting_list input[type="checkbox"]:checked::after { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 15 13' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M14.8185 0.114533C15.0314 0.290403 15.0614 0.605559 14.8855 0.818454L5.00187 12.5L0.113036 6.81663C-0.0618274 6.60291 -0.0303263 6.2879 0.183396 6.11304C0.397119 5.93817 0.71213 5.96967 0.886994 6.18339L5.00187 11L14.1145 0.181573C14.2904 -0.0313222 14.6056 -0.0613371 14.8185 0.114533Z' fill='%2303A9F4' fill-opacity='0.9'/%3E%3C/svg%3E"); position: absolute; top: 1.5px; left: 4.5px; } .CFBetter_setting_menu label, #darkMode_span, #loaded_span { font-size: 16px; } .CFBetter_setting_list { display: flex; flex-wrap: wrap; align-items: center; padding: 10px; margin: 5px 0px; background-color: #ffffff; border-bottom: 1px solid #c9c6c696; border-radius: 8px; justify-content: space-between; } .CFBetter_setting_list.alert_warn { color: #E65100; background-color: #FFF3E0; border: 1px solid #FF9800; margin: 10px 0px; } .CFBetter_setting_list.alert_tip { color: #009688; background-color: #E0F2F1; border: 1px solid #009688; margin: 10px 0px; } .CFBetter_setting_list p:not(:last-child) { margin-bottom: 10px; } .CFBetter_setting_list p:not(:first-child) { margin-top: 10px; } /*设置面板-checkboxs*/ .CFBetter_setting_menu .CFBetter_checkboxs { flex-basis: 100%; display: flex; padding: 8px; margin: 10px 0px 0px 0px; border-bottom: 1px solid #c9c6c696; border-radius: 8px; border: 1px solid #c5cae9; background-color: #f0f8ff; } .CFBetter_setting_menu .CFBetter_checkboxs label { font-size: 13px; margin: 0px 6px 0px 3px; } .CFBetter_setting_menu .CFBetter_checkboxs input[type=checkbox]:checked+label{ color: #7986cb; } .CFBetter_setting_menu .CFBetter_checkboxs input[type="checkbox"] { border: none; width: 16px; height: 16px; } .CFBetter_setting_menu .CFBetter_checkboxs input[type="checkbox"]::before{ background: #ffffff; transform: none; width: 16px; height: 16px; } .CFBetter_setting_menu .CFBetter_checkboxs input[type="checkbox"]:checked { background: none; border: none; } .CFBetter_setting_menu .CFBetter_checkboxs input[type="checkbox"]:checked::before { border: 1.5px solid #95a2de; background: #e8eaf6; transform: none; } .CFBetter_setting_menu .CFBetter_checkboxs input[type="checkbox"]:checked::after { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 15 13' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M14.8185 0.114533C15.0314 0.290403 15.0614 0.605559 14.8855 0.818454L5.00187 12.5L0.113036 6.81663C-0.0618274 6.60291 -0.0303263 6.2879 0.183396 6.11304C0.397119 5.93817 0.71213 5.96967 0.886994 6.18339L5.00187 11L14.1145 0.181573C14.2904 -0.0313222 14.6056 -0.0613371 14.8185 0.114533Z' fill='%2303A9F4' fill-opacity='0.9'/%3E%3C/svg%3E"); top: 0px; left: 3.5px; } /*设置面板-radio*/ .CFBetter_setting_menu label { list-style-type: none; padding-inline-start: 0px; overflow-x: auto; max-width: 100%; margin: 3px 0px; overflow-x: visible; } .CFBetter_setting_menu_label_text { display: flex; border: 1px dashed #00aeeccc; height: 35px; width: 100%; color: #6e6e6e; font-weight: 300; font-size: 14px; letter-spacing: 2px; padding: 7px; margin-bottom: 4px; align-items: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } input[type="radio"]:checked+.CFBetter_setting_menu_label_text { background: #41e49930; border: 1px solid green; color: green; text-shadow: 0px 0px 0.5px green; } .CFBetter_setting_menu label input[type="radio"], .CFBetter_contextmenu label input[type="radio"]{ appearance: none; list-style: none; padding: 0px !important; margin: 0px; clip: rect(0 0 0 0); -webkit-clip-path: inset(100%); clip-path: inset(100%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; } .CFBetter_setting_menu input[type="text"] { display: block; height: 25px !important; width: 100%; background-color: #ffffff; color: #727378; font-size: 12px; border-radius: 0.3rem; padding: 1px 5px !important; box-sizing: border-box; margin: 5px 0px 5px 0px; border: 1px solid #00aeeccc; box-shadow: 0 0 1px #0000004d; } .CFBetter_setting_menu .CFBetter_setting_list input[type="text"] { margin-left: 5px; } .CFBetter_setting_menu input[type="text"]:focus-visible{ border-style: solid; border-color: #3f51b5; outline: none; } .CFBetter_setting_menu_config_box { width: 100%; display: grid; margin-top: 5px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .CFBetter_setting_menu input::placeholder { color: #727378; } .CFBetter_setting_menu input.no_default::placeholder{ color: #BDBDBD; } .CFBetter_setting_menu input.is_null::placeholder{ color: red; border-width: 1.5px; } .CFBetter_setting_menu input.is_null{ border-color: red; } .CFBetter_setting_menu textarea { resize: vertical; display: block; width: 100%; height: 60px; background-color: #ffffff; color: #727378; font-size: 12px; padding: 1px 5px !important; box-sizing: border-box; margin: 5px 0px 5px 0px; border: 1px solid #00aeeccc; box-shadow: 0 0 1px #0000004d; } .CFBetter_setting_menu textarea:focus-visible{ border-style: solid; border-color: #3f51b5; outline: none; } .CFBetter_setting_menu textarea::placeholder{ color: #BDBDBD; font-size: 14px; } .CFBetter_setting_menu #tempConfig_save { cursor: pointer; display: inline-flex; padding: 5px; background-color: #1aa06d; color: #ffffff; font-size: 14px; line-height: 1.5rem; font-weight: 500; justify-content: center; width: 100%; border-radius: 0.375rem; border: none; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); margin-top: 20px } .CFBetter_setting_menu button#debug_button.debug_button { width: 18%; } .CFBetter_setting_menu span.tip { color: #999; font-size: 12px; font-weight: 500; padding: 5px 0px; } /*设置面板-tip*/ .help_tip { margin-right: auto; } span.input_label { font-size: 14px; } .help_tip .tip_text { display: none; position: absolute; color: #697e91; font-weight: 400; font-size: 14px; letter-spacing: 0px; background-color: #ffffff; padding: 10px; margin: 5px 0px; border-radius: 4px; border: 1px solid #e4e7ed; box-shadow: 0px 0px 12px rgba(0, 0, 0, .12); z-index: 100; } .help_tip .tip_text p { margin-bottom: 5px; } .help_tip .tip_text:before { content: ""; position: absolute; top: -20px; right: -10px; bottom: -10px; left: -10px; z-index: -1; } .help-icon { cursor: help; width: 15px; color: #b4b9d4; margin-left: 5px; margin-top: 3px; } .CFBetter_setting_menu .CFBetter_setting_menu_label_text .help_tip .help-icon { color: #7fbeb2; } .help_tip .help-icon:hover + .tip_text, .help_tip .tip_text:hover { display: block; cursor: help; width: 250px; } /*确认弹窗*/ .CFBetter_modal { z-index: 600; display: grid; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 12px; font-family: var(--vp-font-family-base); padding: 10px 20px; box-shadow: 0px 0px 0px 4px #ffffff; border-radius: 6px; background-color: #f0f4f9; border-collapse: collapse; border: 1px solid #ffffff; color: #697e91; } .CFBetter_modal .buttons{ display: flex; padding-top: 15px; } .CFBetter_modal button { display: inline-flex; justify-content: center; align-items: center; line-height: 1; white-space: nowrap; cursor: pointer; text-align: center; box-sizing: border-box; outline: none; transition: .1s; user-select: none; vertical-align: middle; -webkit-appearance: none; height: 24px; padding: 5px 11px; margin-right: 15px; font-size: 12px; border-radius: 4px; color: #ffffff; background: #009688; border-color: #009688; border: none; } .CFBetter_modal button.secondary{ background-color:#4DB6AC; } .CFBetter_modal button:hover{ background-color:#4DB6AC; } .CFBetter_modal button.secondary:hover { background-color: #80CBC4; } .CFBetter_modal .help-icon { margin: 0px 8px 0px 0px; height: 1em; width: 1em; line-height: 1em; display: inline-flex; justify-content: center; align-items: center; position: relative; fill: currentColor; font-size: inherit; } .CFBetter_modal p { margin: 5px 0px; } /*更新检查*/ div#update_panel { z-index: 200; position: fixed; top: 50%; left: 50%; width: 240px; transform: translate(-50%, -50%); box-shadow: 0px 0px 4px 0px #0000004d; padding: 10px 20px 20px 20px; color: #444242; background-color: #f5f5f5; border: 1px solid #848484; border-radius: 8px; } div#update_panel #updating { cursor: pointer; display: inline-flex; padding: 3px; background-color: #1aa06d; color: #ffffff; font-size: 14px; line-height: 1.5rem; font-weight: 500; justify-content: center; width: 100%; border-radius: 0.375rem; border: none; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); } div#update_panel #updating a { text-decoration: none; color: white; display: flex; position: inherit; top: 0; left: 0; width: 100%; height: 22px; font-size: 14px; justify-content: center; align-items: center; } #skip_menu { display: flex; margin-top: 10px; justify-content: flex-end; align-items: center; } #skip_menu .help_tip { margin-right: 5px; margin-left: -5px; } #skip_menu .help-icon { color: #f44336; } /* 配置管理 */ .embed-responsive { height: max-content; padding-bottom: 0px; } .config_bar { height: 70px; width: 100%; display: flex; justify-content: space-between; } li.tempConfig_add_button { cursor: pointer; height: 40px; border: 1px dashed #BDBDBD; border-radius: 8px; background-color: #fcfbfb36; color: #bdbdbd; font-size: 14px; align-items: center; justify-content: center; } li.tempConfig_add_button:hover { border: 1px dashed #03A9F4; background-color: #d7f0fb8c; color: #03A9F4; } .config_bar_list { display: flex; width: 340px; border: 1px solid #c5cae9; border-radius: 8px; background-color: #f0f8ff; box-sizing: border-box; } .config_bar_list input[type="radio"] { appearance: none; width: 0; height: 0; overflow: hidden; } .config_bar_list input[type="radio"] { margin: 0px; } .config_bar_list input[type=radio]:focus { outline: 0px; } label.config_bar_ul_li_text { display: flex; align-items: center; justify-content: center; max-width: 100%; height: 40px; overflow-x: auto; font-size: 14px; font-weight: 400; margin: 0px 4px; padding: 3px; border: 1px solid #dedede; border-radius: 10px; box-shadow: 0px 2px 4px 0px rgba(0,0,0,.05); box-sizing: border-box; } .config_bar_ul li button { background-color: #e6e6e6; color: #727378; height: 23px; font-size: 14px; border-radius: 0.3rem; padding: 1px 5px; margin: 5px; border: none; box-shadow: 0 0 1px #0000004d; } .config_bar_ul { display: flex; align-items: center; list-style-type: none; padding-inline-start: 0px; overflow-x: auto; max-width: 100%; margin: 0px; } .config_bar_ul li { width: 80px; display: grid; margin: 4px 4px; min-width: 100px; box-sizing: border-box; } label.config_bar_ul_li_text:hover { background-color: #eae4dc24; } input[type="radio"]:checked + .config_bar_ul_li_text { background: #41b3e430; border: 1px solid #5e7ce0; color: #5e7ce0; } .config_bar_ul::-webkit-scrollbar { width: 5px; height: 3px; } .config_bar_ul::-webkit-scrollbar-thumb { background-clip: padding-box; background-color: #d7d9e4; border-radius: 8px; } .config_bar_ul::-webkit-scrollbar-button:start:decrement { width: 4px; background-color: transparent; } .config_bar_ul::-webkit-scrollbar-button:end:increment { width: 4px; background-color: transparent; } .config_bar_ul::-webkit-scrollbar-track { border-radius: 5px; } label.config_bar_ul_li_text::-webkit-scrollbar { width: 5px; height: 7px; background-color: #aaa; } label.config_bar_ul_li_text::-webkit-scrollbar-thumb { background-clip: padding-box; background-color: #d7d9e4; } label.config_bar_ul_li_text::-webkit-scrollbar-track { background-color: #f1f1f1; } .config_bar_list_add_div { display: flex; height: 40px; margin: 4px 2px; } /* 修改菜单 */ div#config_bar_menu { z-index: 400; position: absolute; width: 60px; background: #ffffff; box-shadow: 1px 1px 4px 0px #0000004d; border: 0px solid rgba(0,0,0,0.04); border-radius: 4px; padding: 8px 0; } div.config_bar_menu_item { cursor: pointer; padding: 2px 6px; display: flex; justify-content: center; align-items: center; height: 32px; color: rgba(0,0,0,0.75); font-size: 14px; font-weight: 500; box-shadow: inset 0px 0px 0px 0px #8bb2d9; } div#config_bar_menu_edit:hover { background-color: #00aeec; color: white; } div#config_bar_menu_delete:hover { background-color: #FF5722; color: white; } /* 配置页面 */ #config_edit_menu { z-index: 300; width: 450px; } /* 黑暗模式选项 */ .dark-mode-selection { display: flex; justify-content: center; align-items: center; max-width: 350px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .dark-mode-selection label { margin: 8px 0px 8px 8px; } .dark-mode-selection > * { margin: 6px; } .dark-mode-selection .CFBetter_setting_menu_label_text { border-radius: 8px; margin-bottom: 0px; } /* 右键菜单 */ .CFBetter_contextmenu { z-index: 500; display: grid; position: absolute; background-color: #f0f4f9; border-collapse: collapse; color: #697e91; font-family: var(--vp-font-family-base); overflow: hidden; box-sizing: content-box; box-shadow: 0px 0px 0px 2px #eddbdb4d; } input[type="radio"]:checked+.CFBetter_contextmenu_label_text { background: #41e49930; border: 1px solid green; color: green; font-weight: 500; } .CFBetter_contextmenu_label_text { display: flex; border: 1px dashed #80cbc4; height: 26px; width: 100%; color: gray; font-size: 13px; padding: 4px; align-items: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .CFBetter_contextmenu_label_text:hover { color: #F44336; border: 1px dashed #009688; background-color: #ffebcd; } /* RatingByClist */ .ratingBadges, html[data-theme=dark] button.ratingBadges{ font-weight: 700; margin-top: 5px; border-radius: 4px; color: #ffffff00; border: 1px solid #cccccc66; } /* 多选翻译 */ .block_selected{ box-shadow: 0px 0px 0px 1px #FF9800; outline: none; } /* 悬浮菜单 */ .CFBetter_MiniTranslateButton { z-index: 100; display: grid; position: absolute; border-collapse: collapse; fill: #F57C00; background-color: #FFF3E0; overflow: hidden; box-sizing: content-box; box-shadow: 0px 0px 0px 2px #FFE0B2; border-radius: 100%; } .CFBetter_MiniTranslateButton:hover { cursor: pointer; box-shadow: 0px 0px 0px 2px #FFB74D; } /* acmsguru划分块 */ .CFBetter_acmsguru { margin: 0 0 1em!important; } /* 整个代码提交表单 */ #CFBetter_SubmitForm input[type="number"] { width: 40px; color: #009688; appearance: none; padding: 5px 10px; border-radius: 6px; border-style: solid; border: 1px solid #ced4da; } #CFBetter_SubmitForm :focus-visible { outline: none; border: 1px solid #9E9E9E !important; } #CFBetter_SubmitForm .topDiv { display:flex; align-items: center; justify-content: space-between; } #CFBetter_SubmitForm .topDiv .topRightDiv { display:flex; align-items: center; justify-content: space-between; } /* 顶部区域 */ #CFBetter_SubmitForm .topDiv button{ height: 100%; padding: 5px 10px; font-size: 14px; } #CFBetter_SubmitForm .topDiv div#lspStateDiv{ cursor: pointer; margin: 0px 5px; padding: 4px 8px; border: 1px solid; border-radius: 4px; } #CFBetter_SubmitForm .topDiv div#lspStateDiv.await{ border-color: #BBDEFB; color: #2196F3; background-color: #E3F2FD; } #CFBetter_SubmitForm .topDiv div#lspStateDiv.success{ border-color: #C8E6C9; color: #4CAF50; background-color: #E8F5E9; } #CFBetter_SubmitForm .topDiv div#lspStateDiv.error{ border-color: #FFCDD2; color: #F44336; background-color: #FFEBEE; } /* LSP连接Log */ #LSPLog{ width: 500px; height: 500px; position: fixed; top: 50%; left: 50%; padding: 10px; transform: translate(-50%, -50%); border: 1px solid; z-index: 200; background-color: #ffffff; } #LSPLog button{ position: fixed; top: 10px; right: 10px; z-index: 200; } #LSPLog #LSPLogList{ width: 500px; height: 500px; overflow: auto; color: #424242; } #LSPLog li:nth-child(odd){ background-color: #f5f5f5; } #LSPLog details{ padding: 2px; } /* 代码编辑 */ #CFBetter_editor{ box-sizing: border-box; height: 600px; border: 1px solid #d3d3d3; width: 100% !important; display: block; resize: vertical; } #CFBetter_submitDiv{ display: flex; justify-content: space-between; padding-top: 15px; } .CFBetter_SubmitButton { cursor: pointer; font-size: 15px; height: 35px; width: 100px; margin-left: 10px; border-radius: 6px; border: 1px solid #3c9a5f; } #RunTestButton { color: #333; background-color: #fff; border-color: #ccc; } #RunTestButton:hover { background-color: #f5f5f5; } #SubmitButton { color: #fff; background-color: #209978; border-color: #17795E; } #SubmitButton:hover { background-color: #17795e; } #SubmitButton.disabled { background-color: red; animation: shake 0.07s infinite alternate; } @keyframes shake { 0% { transform: translateX(-5px); } 100% { transform: translateX(5px); } } #programTypeId{ padding: 5px 10px; border-radius: 6px; border-style: solid; border: 1px solid #ced4da; color: #212529; } /* 调试 */ .CFBetter_loding{ padding: 6px 0px 0px 5px; height: 22px; } #CompilerSetting{ width: 70%; } #CompilerSetting select, #CompilerSetting textarea{ padding: 4px 10px; border-radius: 6px; border-style: solid; border: 1px solid #ced4da; color: #212529; } #CompilerArgsInput{ width: 100%; height: 35px; margin-bottom: 10px; padding: 5px 10px; border-radius: 6px; box-sizing: border-box; border: 1px solid #ccc; box-shadow: inset 0px 1px 1px rgba(0,0,0,.075); } input#CompilerArgsInput[disabled] { cursor: not-allowed; } #CompilerBox{ display: grid; margin-top: 10px; border: #d0d7de solid 1px; border-radius: 6px; } #CompilerBox > * { margin: 5px; } /* 调试结果 */ #statePanel{ padding: 10px; margin-top: 10px; border: 1px solid #ddd; border-radius: 4px; } .RunState_title:not(:first-child){ margin-top: 20px; } .RunState_title{ font-size: 16px; margin-bottom: 8px; } .RunState_title.error{ color: red; } .RunState_title.ok{ color: #449d44; } /* 自定义样例 */ #customTestBlock { margin-top: 10px; color: #616161; border: 1px solid #d3d3d3; box-sizing: border-box; position: relative; } #customTestBlock #customTests{ border-top: 1px solid #d3d3d3; margin: 0px 0px 40px 0px; } #customTestBlock summary { cursor: pointer; padding: 10px; } #customTestBlock textarea { resize: vertical; } .sampleDiv { color: #727378; background-color: #FAFAFA; padding: 5px; margin-bottom: 10px; box-shadow: inset 0 0 1px #0000004d; position: relative; } .dynamicTextarea { width: 98%; height: 120px; margin: 10px 5px; border: 1px solid #E0E0E0; } .deleteCustomTest { cursor: pointer; position: absolute; top: 5px; right: 5px; display: flex; fill: #9E9E9E; padding: 2px 2px; border-radius: 4px; border: 1px solid #ffffff00; background-color: #ffffff00; align-items: center; } .deleteCustomTest:hover { fill: #EF5350; border: 1px solid #ef9a9a; background-color: #FFEBEE; } #addCustomTest { cursor: pointer; position: absolute; bottom: 5px; right: 5px; padding: 3px 10px; color: #795548; border: 1px solid #ccc; border-radius: 4px; background-color: #FAFAFA; } #addCustomTest:hover { background-color: #f5f5f5; } /* 差异对比 */ .outputDiff { color: #5d4037; margin: 5px 0px; display: grid; border: 1px solid #bcaaa4; font-size: 13px; font-family: Consolas, "Lucida Console", "Andale Mono", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; } .outputDiff .added { background-color: #c8f7c5; user-select: none; } .outputDiff .removed { background-color: #f7c5c5; } .DiffLine { display: flex; } .outputDiff .DiffLine:nth-child(odd) { background-color: #f5f5f5; } .LineNo { display: flex; align-items: center; justify-content: center; width: 17px; color: #BDBDBD; font-size: 10px; border-right: 1px solid; user-select: none; } .LineContent { display: grid; width: 100%; } /*monaco编辑器*/ .monaco-hover hr { margin: 4px -8px 4px !important; } #CFBetter_editor .highlight { border: 1px solid #ffffff00; background-color: #ffffff00!important } #CFBetter_editor.fullscreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 100; } #CFBetter_editor.fixed { position: fixed; right: 0; bottom: 0; height: 50vh; z-index: 100; } #CFBetter_editor.right-side { height: 98vh; } .html2mdButton.exit_button { position: fixed; top: 10px; right: 10px; z-index: 100; height: 28px; padding: 5px 10px; font-size: 14px; } .html2mdButton.exit_button.bottom { top: 95%; } #CFBetter_statusBar{ height: 100%; font-size: 12px; color: #757575; border: 1px solid #d3d3d3; background-color: #f8f8f8; padding: 3px; } /* 移动设备 */ @media (max-device-width: 450px) { button.html2mdButton{ height: 2em; font-size: 1.2em; } button.html2mdButton.CFBetter_setting{ height: 2.5em; font-size: 1em; } .CFBetter_setting_menu{ width: 90%; } .CFBetter_setting_menu label, #darkMode_span, #loaded_span, .CFBetter_setting_menu_label_text, .CFBetter_setting_sidebar li{ font-size: 1em; } .translate-problem-statement{ font-size: 1.2em; } .CFBetter_modal{ font-size: 1.5em; } .CFBetter_setting_list, .translate-problem-statement{ padding: 0.5em; } .CFBetter_setting_menu_label_text{ height: 2.5em; padding: 0.5em; } #pagBar #jump-input, #pagBar #items-per-page, .CFBetter_modal button{ height: 2.5em; font-size: 1em; } .translate-problem-statement p, .translate-problem-statement ul li{ line-height: 1.5em !important; } .CFBetter_contextmenu_label_text{ height: 3em; font-size: 1em; } } `); // 工具 // 获取cookie function getCookie(name) { const cookies = document.cookie.split(";"); for (let i = 0; i < cookies.length; i++) { const cookie = cookies[i].trim(); const [cookieName, cookieValue] = cookie.split("="); if (cookieName === name) { return decodeURIComponent(cookieValue); } } return ""; } // 随机数生成 function getRandomNumber(numDigits) { let min = Math.pow(10, numDigits - 1); let max = Math.pow(10, numDigits) - 1; return Math.floor(Math.random() * (max - min + 1)) + min; } // 防抖函数 function debounce(callback) { let timer; let immediateExecuted = false; const delay = 500; return function () { clearTimeout(timer); if (!immediateExecuted) { callback.call(this); immediateExecuted = true; } timer = setTimeout(() => { immediateExecuted = false; }, delay); }; } // 为元素添加鼠标拖动 function addDraggable(element) { let isDragging = false; let x, y, l, t, nl, nt; let isSpecialMouseDown = false; // 选取某些元素时不拖动 element.on('mousedown', function (e) { isSpecialMouseDown = $(e.target).is('label, p, input, textarea, span, select'); if (isSpecialMouseDown) return; isDragging = true; x = e.clientX; y = e.clientY; l = element.offset().left - $(window).scrollLeft(); t = element.offset().top - $(window).scrollTop(); element.css({ left: l + 'px', top: t + 'px', transform: 'none' }); $(document).on("mousemove", drag); $(document).on("mouseup", stopDrag); element.css('cursor', 'all-scroll'); }); const drag = (e) => { if (!isDragging) return; // 不执行拖动操作 if ($(e.target).is('label, p, input, textarea, span') || isSpecialMouseDown && !$(e.target).is('input, textarea')) return; e.preventDefault(); const nx = e.clientX; const ny = e.clientY; nl = nx - (x - l); nt = ny - (y - t); element.css({ transform: `translate(${nx - x}px, ${ny - y}px)` }); }; const stopDrag = () => { isDragging = false; isSpecialMouseDown = false; element.css('cursor', 'default'); // 在停止拖拽后,设置元素的left和top,并还原transform element.css({ left: nl + 'px', top: nt + 'px', transform: 'none' }); $(document).off("mousemove", drag); $(document).off("mouseup", stopDrag); }; } // 获取外部json并转换为object function getExternalJSON(url) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: "GET", url: url, onload: function (response) { if (response.status === 200) { var json = JSON.parse(response.responseText); resolve(json); } else { console.warn(`网络错误, ${url}无法访问`); resolve({}); } }, onerror: function (response) { console.warn(`网络错误, ${url}无法访问`); resolve({}); } }); }); } /** * 创建确认对话框 * @param {string} title 标题 * @param {string} content 内容 * @param {string[]} buttons 按钮 * @param {"cancel"|"continue"} [secondaryButton="cancel"] 指定次要按钮 * @param {boolean} renderMarkdown 是否使用markdown渲染文本 */ function createDialog(title, content, buttons, secondaryButton = "cancel", renderMarkdown = false) { return new Promise(resolve => { const styleElement = GM_addStyle(darkenPageStyle2); let contentHtml = content; if (renderMarkdown) { const md = window.markdownit(); contentHtml = md.render(content); } let dialog = $(`当你开启 显示加载信息 时,每次加载页面时会在上方显示加载信息提示:“${OJBetterName} —— xxx”
这用于了解脚本当前的工作情况,如果你不想看到,可以选择关闭
需要说明的是,如果你需要反馈脚本的任何加载问题,请开启该选项后再截图,以便于分析问题
开启后当鼠标悬浮在 MD视图/复制/翻译 按钮上时,会显示其目标区域的范围
为折叠块元素添加 contain 约束
contain: layout style;
如果你的浏览器查看大量折叠块时比较卡顿,开启后可能会有一定程度的改善
对评论区分页显示,每页显示指定数量的主楼
洛谷OJ上收录了Codeforces的部分题目,一些题目有翻译和题解
开启显示后,如果当前题目被收录,则会在题目的右上角显示洛谷标志,
点击即可一键跳转到该题洛谷的对应页面。
对于采用 Codeforces 赛制的比赛榜单
按照“得分/总分”所在的范围为分数重新渐变着色
范围:1~0.7~0.45~0 深绿色→浅橙色→深橙色→红色
启用数据流式传输,打字机效果
对于.ttypography, .comments 区域中的短文本,
当其进入浏览器窗口的 可视区域 时自动翻译
指定判断为短文本的最大字符上限,如果超过最大字符数,则为非短文本
自动翻译时,对于评论区中的每一个短文本区域,独立的在下方勾选的服务中随机选择一个,
并行地进行快速翻译
你可以选择脚本的工作方式
○ 普通模式:会一次性翻译整个区域的内容
○ 分段模式:会对区域内的每一个<p/>和<i/>标签依次进行翻译
○ 选段模式:你可以自由点选页面上的任何<p/>和<i/>标签进行翻译
注意:分段/选段模式会产生如下问题:
- 使得翻译接口无法知晓整个文本的上下文信息,会降低翻译质量。
- 会有部分内容不会被翻译/不能被选中,因为它们不是<p/>或<i/>元素
将题目页面上的翻译信息自动保存到本地indexDB中
刷新 / 下一次进入页面 时自动恢复翻译信息
选择在重新翻译时是"关闭旧的结果"还是"收起旧的结果"
设置两次翻译请求间的等待间隔,该设置会全局生效,各个翻译服务之间独立计算
建议 200 + 毫秒
说明:ChatGPT 翻译时会忽略该设置,不等待
脚本通过先取出所有的LaTeX公式,并使用替换符占位,来保证公式不会被翻译接口所破坏
对于各个翻译服务,不同的替换符本身遭到破坏的概率有所不同,具体请阅读脚本页的说明
注意:使用ChatGPT翻译时不需要上述操作, 因此不受此选项影响
具体你可以前往阅读脚本页的说明
一些翻译服务(比如 DeepL)会错误处理 MarkDown 中的着重号 **
这可能会导致翻译结果漏掉其包裹的内容,你可以选择将着重号去掉 (使用ChatGPT会忽略该项)
注意:在不同页面工作所需要的凭证有所不同,具体请看对应选项的标注说明
格式样例:
ApiKey XXXXXXXXX
数据来源clist.by
你需要提供官方的api key
或让你的浏览器上的clist.by处于登录状态(即cookie有效)
你需要提供官方的api key
或让你的浏览器上的clist.by处于登录状态(即cookie有效)
需要让你的浏览器上的clist.by处于登录状态(即cookie有效)才能正常工作
只有当鼠标移动到Rating分展示区域上时才显示
在题目页下面添加Monaco编辑器,代码会自动保存,提供在线代码运行
点击题目页Monaco编辑器的代码提交时会弹窗二次确认,防止误提交
连接 LSP Server,以启用代码补全、代码诊断、格式化、转到定义等功能
支持C++、Python语言
你需要启动 OJBetter_Bridge ,具体请查看脚本页的说明
你需要填写 OJBetter_Bridge 所在的路径:
使用正斜杠或反斜杠均可
默认路径:
C:/OJBetter_Bridge
你需要填写你本机中 OJBetter_Bridge 的 Server URL
默认的URL:
ws://127.0.0.1:2323/
注意,你通常不需要更改这里,如需更改,请与默认URL格式一致
模板来自AcWing
注意:过多的静态补全规则会影响性能
为了防止在页面资源未加载完成前(主要是各种js)执行脚本产生意外的错误,脚本默认会等待 window.onload 事件
如果你的页面上方的加载信息始终停留在:“等待页面资源加载”,即使页面已经完成加载
你首先应该确认是否是网络问题,
如果不是,那这可能是由于 window.onload 事件在你的浏览器中触发过早(早于DOMContentLoaded),
你可以尝试开启该选项来不再等待 window.onload 事件
注意:如果没有上述问题,请不要开启该选项