No magic

Disable magic on CF

2019-12-30 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         No magic
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Disable magic on CF
// @author       ouuan
// @match        *://codeforces.com/*
// @match        *://codeforc.es/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var handlesElements = document.getElementsByClassName('rated-user');

    var handles = '';
    var handleElements = {};

    for (var i = 0; i < handlesElements.length; ++i) {
        var handleElement = handlesElements[i];
        var ttypography = false;
        for (var u = handleElement; u.parentNode; u = u.parentNode) if (u.className == 'ttypography') ttypography = true;
        if (ttypography) continue;
        console.log(handleElement);
        var handle = handleElement.innerText;
        if (i > 0) handles += ';';
        handles += handle;
        if (handleElements.hasOwnProperty(handle)) handleElements[handle].push(handleElement);
        else handleElements[handle] = [handleElement];
    }

    var xmlHttp = new XMLHttpRequest();

    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            var response = xmlHttp.response.result;
            for (var i = 0; i < response.length; ++i) {
                var user = response[i];
                var color = 'rated-user user-';
                var lgm = false;
                if (!user.hasOwnProperty('rank')) color += 'black';
                else if (user.rank == 'newbie') color += 'grey';
                else if (user.rank == 'pupil') color += 'green';
                else if (user.rank == 'specialist') color += 'cyan';
                else if (user.rank == 'expert') color += 'blue';
                else if (user.rank == 'candidate master') color += 'violet';
                else if (user.rank == 'master' || user.rank == 'international master') color += 'orange';
                else color += 'red';
                if (user.rank == 'legendary grandmaster') lgm = true;
                for (var j = 0; j < handleElements[user.handle].length; ++j) {
                    var u = handleElements[user.handle][j];
                    u.className = color;
                    if (lgm) u.innerHTML = '<span class="legendary-user-first-letter">' + user.handle[0] + '</span>' + user.handle.substring(1);
                    else u.innerHTML = user.handle;
                }
            }
        } else {
            console.log(xmlHttp.response);
        }
    }

    xmlHttp.responseType = 'json';
    xmlHttp.open('GET', 'https://codeforces.com/api/user.info?handles=' + handles, true);
    xmlHttp.send(null);
})();