Codeforces Match Enhancer.

auto insert problem id and language in match.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Codeforces Match Enhancer.
// @namespace   Violentmonkey Scripts
// @match       https://m1.codeforces.com/contest/*/submit
// @match       https://m2.codeforces.com/contest/*/submit
// @match       https://m3.codeforces.com/contest/*/submit
// @grant       none
// @version     1.2
// @author      dianhsu
// @license     MIT
// @run-at      document-idle
// @homepageURL https://greasyfork.org/zh-CN/scripts/484960-codeforces-match-enhancer
// @supportURL  https://github.com/dianhsu/cf-code/issues
// @description auto insert problem id and language in match.
// ==/UserScript==

$(function () {
  'use strict';
  // get problem id from referrer url.
  const re = new RegExp("^https://[0-9a-z]+.codeforces.com/contest/[0-9]+/problem/([0-9a-zA-Z]+)$");
  if (re.test(document.referrer)) {
    let arr = re.exec(document.referrer);
    document.getElementById("problemIndex").value = arr[1];
  } else {
    console.debug("No valid referrer found.")
  }

  // load language from local storage and update selector.
  let lid = localStorage.getItem("programTypeId");
  document.getElementById("programTypeId").value = lid;
  // add event listener to watch selector changes.
  document.getElementById("programTypeId").addEventListener('change', function() {
    console.log('You selected: ', this.value);
    localStorage.setItem("programTypeId", this.value);
  });
});