CodeChef → VJudge Redirect

从 CodeChef 题目页面自动跳转到对应的 VJudge 页面

Versione datata 12/09/2025. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         CodeChef → VJudge Redirect
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  从 CodeChef 题目页面自动跳转到对应的 VJudge 页面
// @author       znzryb
// @match        https://www.codechef.com/problems/*
// @grant        none
// @license GPL-3.0
// ==/UserScript==

(function() {
    'use strict';

    // 从 URL 中提取题目标识符
    const pathParts = window.location.pathname.split('/');
    // URL 格式通常是 /problems/PERMCNTEZ 或带参数中的 /problems/PERMCNTEZ?tab=statement
    const problemCode = pathParts[2];
    if (!problemCode) return;

    // 构造 VJudge 的链接
    const vjudgeUrl = `https://vjudge.net/problem/CodeChef-${problemCode}`;

    // 自动跳转(可根据需要取消注释)
    // window.location.href = vjudgeUrl;

    // 或者添加一个按钮,供用户点击跳转
    const btn = document.createElement('button');
    btn.textContent = 'Jump to VJudge';
    Object.assign(btn.style, {
        position: 'fixed',
        top: '100px',
        right: '20px',
        padding: '10px 15px',
        backgroundColor: '#28a745',
        color: '#fff',
        border: 'none',
        borderRadius: '4px',
        cursor: 'pointer',
        fontSize: '14px',
        zIndex: 10000
    });
    btn.onclick = () => window.open(vjudgeUrl, '_blank');
    document.body.appendChild(btn);
})();