atcoder-problem-navigator

Shows a navigation bar on AtCoder contest pages for jumping to problems.

23.05.2019 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         atcoder-problem-navigator
// @namespace    https://github.com/yoshrc
// @version      1.0
// @description  Shows a navigation bar on AtCoder contest pages for jumping to problems.
// @author       yoshrc
// @match        https://atcoder.jp/contests/*
// @grant        none
// @require http://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==

(function() {
    'use strict';
    const scriptName = 'atcoder-problem-navigator';

    const contest = location.href.match(/^https:\/\/atcoder\.jp\/contests\/([^\/]+)/)[1];
    const key = scriptName + "-" + contest;

    if (location.href.match(/^https:\/\/atcoder\.jp\/contests\/([^\/]+)\/tasks\/?$/)) {
        console.log(contest);
        const problems = [];
        const $rows = $('tbody>tr');
        for (let i = 0; i < $rows.length; i++) {
            console.log(i);
            const $links = $rows.eq(i).find('a');
            const href = $links.eq(0).attr('href');
            console.log(href);
            const text = $links.eq(0).text() + " - " + $links.eq(1).text();
            problems.push({
                href: href,
                text: text
            });
        }
        localStorage[key] = JSON.stringify(problems);
    }

    if (key in localStorage) {
        let problems = JSON.parse(localStorage[key]);
        const $contestBar = $('#contest-nav-tabs');
        const $problemsBar = $('<ul class="nav nav-tabs"></ul>');
        for (let i = 0; i < problems.length; i++) {
            const $span = $('<span style="margin-left: 10px; margin-right: 10px; white-space: nowrap"></span>')
            const $link = $('<a></a>')
                  .attr('href', problems[i].href)
                  .text(problems[i].text);
            $span.append($link);
            const $separator = $('<span></span>');
            $problemsBar.append($span);
            $problemsBar.append($separator);
        }
        $contestBar.append($problemsBar);
    }
})();