AtCoder Add Submissions Shortcuts

Add links to the AtCoder task page that open a list of submissions for the current task with custom filters applied.

Stan na 07-04-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name            AtCoder Add Submissions Shortcuts
// @name:ja         AtCoder Add Submissions Shortcuts
// @namespace       https://github.com/xe-o
// @version         0.1
// @description     Add links to the AtCoder task page that open a list of submissions for the current task with custom filters applied.
// @description:ja  AtCoderの各問題ページのタブメニューに対して、任意のフィルター・並び順を適用した状態でその問題の提出一覧を開くリンクを追加します。
// @author          XERO
// @license         MIT
// @match           https://atcoder.jp/contests/*/tasks/*
// @grant           none
// ==/UserScript==

{
  const buttonSettings = {
    fastest: {
      label: "Fastest",
      icon: "time",
      urlParams: "f.Status=AC&orderBy=time_consumption",
    },
    shortest: {
      label: "Shortest",
      icon: "flag",
      urlParams: "f.Status=AC&orderBy=source_length",
    },
  };

  const buttons = Object.entries(buttonSettings).map(
    ([buttonName, { label, icon, urlParams }]) => {
      const taskName = window.location.pathname.split("/").pop();
      const buttonUrl = `https://atcoder.jp/contests/${
        window.location.pathname.split("/")[2]
      }/submissions?${urlParams}&f.Task=${taskName}`;
      return `<li><a href="${buttonUrl}"><span class="glyphicon glyphicon-${icon}" style="margin-right:4px;" aria-hidden="true"></span>${label}</a></li>`;
    }
  );

  const pullRightListItem = document.querySelector("li.pull-right");
  buttons.forEach((buttonHtml) => {
    pullRightListItem.insertAdjacentHTML("beforebegin", buttonHtml);
  });
}