AtCoder Profile2Ranking Link

link the profile page to the ranking of country/region, birth year, and affiliation

2021-05-09 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         AtCoder Profile2Ranking Link
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  link the profile page to the ranking of country/region, birth year, and affiliation
// @author       sotanishy
// @match        https://atcoder.jp/users/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    let table = document.getElementsByClassName('dl-table')[0];
    let tbody = table.getElementsByTagName('tbody')[0];
    let tr = tbody.getElementsByTagName('tr');
    const baseUrl = 'https://atcoder.jp/ranking';

    for (let i = 0; i < tr.length; i++) {
        let head = tr[i].getElementsByTagName('th')[0].textContent;
        let td = tr[i].getElementsByTagName('td')[0];
        if (head == '国と地域' || head == 'Country/Region') {
            let img = td.getElementsByTagName('img')[0];
            let country = img.src.split('/')[5].split('.')[0];
            let a = document.createElement('a');
            a.textContent = td.textContent;
            td.textContent = '';
            a.href = `${baseUrl}?f.Country=${country}`;
            td.appendChild(img);
            td.appendChild(a);
        }
        if (head == '誕生年' || head == 'Birth Year') {
            let birthyear = td.textContent;
            let a = document.createElement('a');
            a.textContent = birthyear;
            td.textContent = '';
            a.href = `${baseUrl}?f.BirthYearLowerBound=${birthyear}&f.BirthYearUpperBound=${birthyear}`;
            td.appendChild(a);
        }
        if (head == '所属' || head == 'Affiliation') {
            let affiliation = td.textContent;
            let a = document.createElement('a');
            a.textContent = affiliation;
            td.textContent = '';
            a.href = `${baseUrl}?f.Affiliation=${affiliation.replace(' ', '+')}`;
            td.appendChild(a);
        }
    }
})();