版本比较
Luogu-to-Vjudge:一键跳转 VJudge 脚本
标题
增加 1 行删除 1 行
1Luogu-to-Vjudge:平替 RMJ 刷题效率神器1Luogu-to-Vjudge:一键跳转 VJudge 脚本
正文
增加 75 行删除 65 行
12345678910111213141516171819202122236 行未改动303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221238 行未改动# 一键跳转 VJudge 脚本> 新版同步于 [GitHub 仓库](https://github.com/Justskr/Luogu-to-Vjudge),可以去 Star 一下。>> 保命声明:完全开源免费,拒绝商业化。仅供学术研究,严禁用于一切非正当行为。## 脚本简介**洛谷** 和 **VJudge** 是两大高频使用的平台:- 洛谷题量丰富、社区活跃;- VJudge 支持多平台题目聚合、组队训练。二者结合能大幅提升刷题效率。随着洛谷 RMJ 下线,刷其他 OJ 的题目不再方便,而 VJudge 仍可提交 CF、AT、SPOJ 等题目,自由度较高。于是就有了这个脚本(网上旧脚本因洛谷新版 UI 已失效)。优点如下:### 方便快捷手动在两个平台间切换、查找对应编号耗时费力。**「洛谷一键跳转 VJudge」** 脚本适配洛谷新版 UI,支持 **CF / SPOJ / AtCoder / UVA** 四大平台题目一键跳转,自动识别题目编号并拼接 VJudge 链接,让跨平台刷题一步到位。### 美观大气6 行未改动## 使用指南### 步骤 1:安装脚本管理器在浏览器扩展商店搜索并安装 **Tampermonkey** 或 **Violentmonkey**。相信很多人都喜欢用脚本优化做题体验。比如我:### 步骤 2:添加脚本1. 打开 [GitHub 仓库](https://github.com/Justskr/Luogu-to-Vjudge) 下载源文件,脚本管理器会自动接管安装;2. 若未自动安装,可在脚本管理器内「新建用户脚本」,粘贴以下内容后保存:```javascript// ==UserScript==// @name 洛谷 RMJ 一键跳转 VJudge// @namespace http://tampermonkey.net/// @version 3.0// @description 支持洛谷 CF / SPOJ / AtCoder / UVA 题目跳转 VJudge,自动匹配各平台链接格式// @author Justskr// @match https://www.luogu.com.cn/problem/CF*// @match https://www.luogu.com.cn/problem/SP*// @match https://www.luogu.com.cn/problem/AT*// @match https://www.luogu.com.cn/problem/UVA*// @grant none// ==/UserScript==(function () {'use strict';function getVjudgeUrl() {const path = location.pathname;if (path.startsWith('/problem/AT_')) {const m = path.match(/AT_(\w+)/);return m ? `https://vjudge.net/problem/AtCoder-${m[1]}` : null;}if (path.startsWith('/problem/UVA')) {const m = path.match(/UVA(\d+)/);return m ? `https://vjudge.net/problem/UVA-${m[1]}` : null;}if (path.startsWith('/problem/CF')) {const m = path.match(/CF(\d+[A-Za-z]*)/);return m ? `https://vjudge.net/problem/CodeForces-${m[1]}` : null;}if (path.startsWith('/problem/SP')) {// 优先抓取页面中的 spoj.com/problems/ 链接const link = document.querySelector('a[href*="spoj.com/problems/"]');if (link) {const id = link.href.split('/problems/')[1].replace(/\/$/, '');return `https://vjudge.net/problem/SPOJ-${id}`;}// 兜底:从正文文本匹配const text = document.body.innerText;const m = text.match(/SPOJ\s*[-:\s]([A-Za-z0-9_-]+)/i);if (m) return `https://vjudge.net/problem/SPOJ-${m[1].trim()}`;return null;}return null;}const copyBtn = [...document.querySelectorAll('button')].find(btn => btn.textContent.trim() === '复制题目');const vjudgeUrl = getVjudgeUrl();if (copyBtn && vjudgeUrl) {const jumpBtn = document.createElement('button');jumpBtn.textContent = '跳转 VJudge';// 复制样式const cs = getComputedStyle(copyBtn);['backgroundColor', 'color', 'border', 'borderRadius','padding', 'fontSize', 'fontFamily', 'cursor', 'height','lineHeight', 'textAlign', 'whiteSpace', 'verticalAlign','display', 'marginTop', 'marginBottom'].forEach(k => jumpBtn.style[k] = cs[k]);jumpBtn.style.marginLeft = '6px';jumpBtn.style.minWidth = cs.minWidth || '80px';jumpBtn.addEventListener('click', () => window.open(vjudgeUrl, '_blank'));copyBtn.parentNode.insertBefore(jumpBtn, copyBtn.nextSibling);} else if (!vjudgeUrl) {const pf = location.pathname.match(/\/problem\/(\w+)/)?.[1].slice(0, 2) || '??';console.warn(`[Luogu2VJ] 未识别到有效题目标识符(平台:${pf})`);}})();```### 步骤 3:一键跳转,即刻体验8 行未改动123456789101112131415161718192021222324256 行未改动32333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321338 行未改动# 一键跳转 VJudge 脚本> 新版同步于 [GitHub 仓库](https://github.com/Justskr/Luogu-to-Vjudge),可以去 Star 一下。>> 保命声明:完全开源免费,拒绝商业化。仅供学术研究,严禁用于一切非正当行为。脚本使用了 AI 辅助制作,本文章仅作为分享,希望可以优化各位的做题体验。>> 2025-11-24 upt:更新了脚本源码,修复了一些跳转bug。重新提交审核,感谢管理员。## 脚本简介**洛谷** 和 **VJudge** 是两大高频使用的平台:- 洛谷题量丰富、社区活跃;- VJudge 支持多平台题目聚合、组队训练。二者结合能大幅提升刷题效率。随着洛谷 RMJ 下线,刷其他 OJ 的题目不再方便,而 VJudge 仍可提交 CF、AT、SPOJ 等题目,自由度较高。于是就有了这个脚本(网上旧脚本因洛谷新版 UI 已失效)。### 方便快捷手动在两个平台间切换、查找对应编号耗时费力。**「洛谷一键跳转 VJudge」** 脚本适配洛谷新版 UI,支持 **CF / SPOJ / AtCoder / UVA** 四大平台题目一键跳转,自动识别题目编号并拼接 VJudge 链接,让跨平台刷题一步到位。### 美观大气6 行未改动## 使用指南### 步骤 1:安装脚本管理器在浏览器扩展商店搜索并安装 **Tampermonkey** 或 **Violentmonkey**。相信很多人都喜欢用脚本优化做题体验。比如我:### 步骤 2:添加脚本1. 打开 [GitHub 仓库](https://github.com/Justskr/Luogu-to-Vjudge) 下载源文件,脚本管理器会自动接管安装;2. 若未自动安装,可在脚本管理器内「新建用户脚本」,粘贴以下内容后保存:```javascript// ==UserScript==// @name 洛谷rmj一键跳转VJudge// @namespace http://tampermonkey.net/// @version 3.1// @description 支持洛谷CF/SPOJ/AtCoder/UVA题目跳转VJudge,修复CF带数字后缀的编号匹配// @author Justskr// @match https://www.luogu.com.cn/problem/CF*// @match https://www.luogu.com.cn/problem/SP*// @match https://www.luogu.com.cn/problem/AT*// @match https://www.luogu.com.cn/problem/UVA*// @grant none// ==/UserScript==(function() {'use strict';function getVjudgeUrl() {const luoguUrl = window.location.href;const luoguPath = window.location.pathname;if (luoguPath.startsWith('/problem/AT_')) {const atMatch = luoguPath.match(/AT_(\w+)/);return atMatch ? `https://vjudge.net/problem/AtCoder-${atMatch[1]}` : null;}else if (luoguPath.startsWith('/problem/UVA')) {const uvaMatch = luoguPath.match(/UVA(\d+)/);return uvaMatch ? `https://vjudge.net/problem/UVA-${uvaMatch[1]}` : null;}else if (luoguPath.startsWith('/problem/CF')) {// 修复CF编号匹配const cfMatch = luoguPath.match(/CF(\d+[A-Za-z\d]*)/);return cfMatch ? `https://vjudge.net/problem/CodeForces-${cfMatch[1]}` : null;}else if (luoguPath.startsWith('/problem/SP')) {let spojId = null;const originalLink = document.querySelector('a[href*="spoj.com/problems/"]');if (originalLink) {spojId = originalLink.href.split('/problems/')[1].replace('/', '');}else {const pageText = document.body.innerText;const spojTextMatch = pageText.match(/SPOJ\s*[-\s:]([A-Za-z0-9_-]+)/i);spojId = spojTextMatch ? spojTextMatch[1].trim() : null;}return spojId ? `https://vjudge.net/problem/SPOJ-${spojId}` : null;}return null;}const copyBtn = Array.from(document.querySelectorAll('button')).find(btn => btn.innerText.trim() === '复制题目');const vjudgeUrl = getVjudgeUrl();if (copyBtn && vjudgeUrl) {const jumpBtn = document.createElement('button');jumpBtn.innerText = '跳转VJudge';const copyStyles = window.getComputedStyle(copyBtn);['backgroundColor', 'color', 'border', 'borderRadius','padding', 'fontSize', 'fontFamily', 'cursor', 'height','lineHeight', 'textAlign', 'whiteSpace', 'verticalAlign','display', 'marginTop', 'marginBottom'].forEach(styleProp => {jumpBtn.style[styleProp] = copyStyles[styleProp];});jumpBtn.style.marginLeft = '5px';jumpBtn.style.minWidth = copyStyles.minWidth || '80px';jumpBtn.addEventListener('click', () => {window.open(vjudgeUrl, '_blank');});copyBtn.parentNode.insertBefore(jumpBtn, copyBtn.nextSibling);}else if (!vjudgeUrl) {const platform = luoguPath.match(/\/problem\/(\w+)/)[1].slice(0, 2);console.warn(`洛谷${platform}题目跳转VJudge:未找到有效题目标识符,请检查页面格式`);}})();```### 步骤 3:一键跳转,即刻体验8 行未改动