CodeForces Solution Opener

Quickly find fastest solution.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        CodeForces Solution Opener
// @namespace   slbtty.codeforces.solution
// @match       https://codeforces.*/problemset/problem/*/*
// @match       https://codeforces.*/contest/*/problem/*
// @grant       none
// @license     GPLv3
// @version     1.1.1
// @home-url    https://github.com/shenlebantongying
// @author      slbtty
// @description Quickly find fastest solution.
// ==/UserScript==

const url = document.URL
url_parts=url.split("/")

if(url_parts.includes('contest')){
  var new_url = "https://codeforces.com/problemset/status/"
                +url_parts[url_parts.length-3]
                +"/problem/"
                +url_parts[url_parts.length-1]
                +"?order=BY_CONSUMED_TIME_ASC"
} else {
  var new_url = "https://codeforces.com/problemset/status/"
                +url_parts[url_parts.length-2]
                +"/problem/"
                +url_parts[url_parts.length-1]
                +"?order=BY_CONSUMED_TIME_ASC"
}

var mainMenu = document.querySelector(".main-menu-list");

var solution_li = document.createElement("li");

var btn = document.createElement('a');
btn.setAttribute('href',new_url);
btn.innerHTML = "Solution";

solution_li.appendChild(btn);
mainMenu.appendChild(solution_li);