Ex124OJ

Extend 124OJ!

Verzia zo dňa 13.12.2022. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         Ex124OJ
// @namespace    http://tampermonkey.net/
// @version      0.7.3
// @description  Extend 124OJ!
// @author       Sukwants
// @license      MIT
// @match        http://124.221.194.184
// @match        http://124.221.194.184/*
// @icon         https://www.imageoss.com/images/2022/11/29/ex124OJba563861978a769d.png
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @connect      ex124oj.netlify.app
// ==/UserScript==


/* ==User Settings== */

// Special Period
const WhenMourn = false;
// Change Page Background. (Image URL, Opacity)
const BackgroundSettings = [];
// Change Site Icon. (Image URL)
const SiteIconImage = 'https://www.imageoss.com/images/2022/11/29/ex124OJba563861978a769d.png';
// Change username color.
const NameColorList = {'Sukwants':['#8e44ad'],'Star32':['#e74c3c'],'2745518585':['#996600'],'syysongyuyang':['#ffc116'],'zsq147258369':['#52c41a'],'zhouchuan':['#e74c3c','#000000']};
// Add CCF level badge.
const CCFBadgeList = {'zsq147258369':'#52c41a','syysongyuyang':'#ffc116'};
// Add name tag badge.
const TagBadgeList = {'Sukwants':['#8e44ad','旅客'],'Star32':['#e74c3c','陌生人'],'2745518585':['#996600','作弊者'],'syysongyuyang':['#ffc116','原批'],'zsq147258369':['#52c41a','boring'],'zhouchuan':['#e74c3c','Feyn']};


const HomepageRegExp = /^http:\/\/124.221.194.184(\/){0,1}(\?.*){0,1}$/;
function isHomepage() {
    return HomepageRegExp.test(window.location.href);
}
const submissionRegExp = /^http:\/\/124.221.194.184\/submission\/\d{1,}/;
function isSubmission() {
    return submissionRegExp.test(window.location.href);
}
const ProblemRegExp = /^http:\/\/124.221.194.184.*\/problem\/(\d{1,})(\?.*){0,1}$/;
function isProblem() {
    return ProblemRegExp.test(window.location.href);
}
const UserProfileRegExp = /^http:\/\/124.221.194.184\/user\/profile\/.{1,}/;
function isUserProfile() {
    return UserProfileRegExp.test(window.location.href);
}
const BlogRegExp = /^http:\/\/124.221.194.184\/blog\/.{1,}/;
function isBlog() {
    return BlogRegExp.test(window.location.href);
}

function whenMourn() {
    if (WhenMourn && isHomepage()) {
        GM_addStyle('\
html {\
-webkit-filter: grayscale(100%);\
-moz-filter: grayscale(100%);\
-ms-filter: grayscale(100%);\
-o-filter: grayscale(100%);\
filter: grayscale(100%);\
filter: gray;\
}');
    }
}

const TrollingArticle = ['巨大的灰色乌云笼罩在灰色的、各式各样的建筑之上,炫目的LED灯管被竖直放置于C市的各个角落。深灰的马路上粉刷着浅灰的虚线和实线,引导着川流不息、来来往往的车辆与人群。\n\
C市的一天,便这样开始了。',
'2050年,地球环境进一步恶化,人类生存资源濒临枯竭,即使科技再高速发展也无济于事。但此时,人类的基因已经完全破译,每个区段每一对碱基对控制着什么形状早已能够被识别、控制与修改。为了维护社会秩序,掌管C市的P党在该技术萌芽时便花重金将专利从相关公司手中买下,垄断了这一技术。所以,这达成了P党内部核心人员一个心照不宣的秘密。',
'15年前。巨大的双链DNA模型在房间内投影出来,右旋的优美轮廓让在场的所有科学家都赞叹不已。喧哗声中,一个人走上演讲台,调试好麦克风,开始了它的发言。\n\
“大家好。正如大家所知,人的眼睛是根据所看见光的波长来识别颜色的,而可见光谱中的大部分颜色可以由三种基本色光红、绿、蓝按不同比例混合而成,形成了连续的可视光谱。人类肉眼能区分其中的几百万至一千万种。经过十余年的研究,我们发现人类基因中关于色彩识别的区段较为冗长;为降低生活成本,我代表P党在此宣布自今年1月1日00:00起将C市所有居民基因中的色彩识别区段删除,仅保留黑白两种基本色光。同时,相关政策也将陆续实施,感谢各位的理解与支持。”\n\
……',
'2034年12月31日,23:58。此时,C市的广大人民群众还不知道他们即将面临什么,有的已早早入睡,有的还在五彩斑斓的繁华都市中享受着绚烂多彩的生活。市中心高楼上的始终嘀嗒,分针逐渐指向了12的正下方。\n\
00:00。\n\
所有还醒着的人们的记忆模块被完全刷新。\n\
“这是一个非黑即白的世界。”\n\
“灰色由不同比例的黑白色组成,是最常见的一种颜色。”\n\
“自古以来便是这样。”\n\
所以,这场历史性的革命在悄无声息中圆满完成了。没有骚动,没有恐慌。',
'与此同时,电子课本、电子词典被同步刷新。颜料标签被迅速替换。文字与影像资料被大幅度删改,相关学科被取消。红、黄、绿灯依次换为圆形、方形、三角形灯。颜色引导标识改为黑白点线面组合引导标识。\n\
……\n\
一切的一切,归零。\n\
生活照常。',
'2030年,C市成为E国少数几个未通过《全可视区段色彩使用法案》的国家。P党声称此法案与C市传统颜色阶级制度价值观不符,不利于人口增长,可能引发社会混乱。此前,C市已出现多次因争取全区段可视色彩使用权而导致舆论风波的现象,重重封锁也无济于事。同时,其声称外部势力也在对C市青少年以各种潜移默化的方式渗透色彩多元化共存理论,造成了巨大影响。为了彻底解决这一问题,P党最后做出了取消色彩可视化这一决定,才有了这场看似荒谬的颜色革命。',
'雨后,晴空。天边罕见地出现了一道彩虹,只是再也无法被C市的孩子们看见了。但他们还从课本上了解过这一自然景观,它被称为“灰虹”,天空中呈现了七种不同深浅的黑白色条带,蔚为壮观。\n\
小朋友们发出天真无邪的笑声,在浅灰的草坪上和父母一起欣赏美丽的灰虹。\n\
风也轻轻。\n\
……',
'但那无法被看见色彩的彩虹,它还存在着啊。幸好,C市的科学还没有发展到能将彩虹粉刷为黑白的地步,幸好,它改变的只是我们人类本身。不论你是否承认彩虹的赤橙黄绿青蓝紫,它都存在着,从古至今。只是对C市的人来说,看不见了罢。\n\
带着无色的双眼去看待这个世界,世界当然是没有颜色的啊。',
'或许会问,为什么那些所谓的“外部势力”没有到C市来宣传呢?\n\
因为C市早已故步自封了呢。C市早已在城郊筑好了高墙,外部势力很难进入,内部民众也难以出去。大家的梯子都被没收了,那可是违法的啊。\n\
从前,颜色是有阶级限制的,P党内部核心人员身穿黄色,大官穿紫色,小吏穿青绿色,平民穿灰白色。倘若僭越,是要遭来杀身之祸的。现在可好,民主、自由、平等,大家都一样,没人管你穿什么颜色,只是深深浅浅罢了。果然,社会进步,百姓安康。',
'深夜,高楼。P党那位发表演讲的科学家站在窗边,望着依旧五光十色的建筑,冷笑一声,又走进无边的黑暗。\n\
……\n\
“又经过几年的研究,我们发现人类基因中关于色彩识别的区段没有其存在的必要性。为进一步降低生活生产成本,我代表P党在此宣布自今年1月1日00:00起将C市所有居民基因中色彩识别区段全部删除。同时,相关政策也将陆续实施。”“感谢各位的理解与支持。”',
'00:00。\n\
C市的人全都瞎了。\n\
没有骚动,没有恐慌。'];
function trollForAmusement() {
    console.log(TrollingArticle[Math.floor(Math.random() * TrollingArticle.length)]);
}

function getBackground() {
    if (BackgroundSettings[0]) return BackgroundSettings[0];
    else return '';
}
function getOpacity() {
    if (BackgroundSettings[1]) return BackgroundSettings[1];
    else return '0.85';
}
function BackgroundImage() {
    if (BackgroundSettings[0]) {
        document.getElementsByClassName('navbar-brand')[0].innerHTML = '<img src="http://124.221.194.184/images/logo_small.png" alt="Logo" class="img-rounded" style="width:39px; height:39px;">';
        document.getElementsByClassName('container')[0].children[0].children[1].innerHTML = document.getElementsByClassName('container')[0].children[0].children[1].innerHTML.match(/(.*> ){0,1}(.*)/)[2];
        GM_addStyle('\
body {\
background: url("' + getBackground() + '");\
background-repeat: no-repeat;\
background-attachment: fixed;\
background-position: 50% 50%;\
background-size: cover;\
}\
.uoj-content {\
background-color: #fff;\
margin: 16px -16px;\
padding: 16px 16px;\
opacity: ' + getOpacity() + ';\
border-radius: 8px;\
}\
.navbar {\
margin: 16px -16px;\
padding: 8px 16px;\
opacity: ' + getOpacity() + ';\
border-radius: 8px;\
}');
    }
}

function getIcon() {
    if (SiteIconImage) return SiteIconImage;
    else return '/images/logo.png';
}
const LogoURLExp = /^.*\/images\/logo(_small){0,1}.png$/;
function changeIcon() {
    var Links = document.getElementsByTagName('link');
    for (var link in Links) {
        if (Links[link] && Links[link].nodeType && Links[link].getAttribute('rel') == 'shortcut icon') {
            Links[link].setAttribute('href', getIcon());
        }
    }
    var Icons = document.getElementsByTagName('img');
    for (var icon in Icons) {
        if (Icons[icon] && Icons[icon].nodeType && LogoURLExp.test(Icons[icon].getAttribute('src'))) {
            Icons[icon].setAttribute('src', getIcon());
            if (!Icons[icon].getAttribute('style')) Icons[icon].setAttribute('style', 'width:100%;height:100%');
        }
    }
}

function HomepageEntrance() {
    var ent = document.createElement('li');
    ent.setAttribute('class', 'nav-item');
    ent.innerHTML = '<a href="https://ex124oj.netlify.app" style="padding: 0.5rem 1rem"><span style="background-color: #28adca;padding:0.2em 0.6em;border-radius: 1em;color:#fff;font-size: 0.7em;font-weight:bold;display:inline-block;position: relative;top: 50%;transform: translate(0,-50%);">Ex124OJ</span></a>';
    document.getElementsByClassName('container')[0].children[0].children[0].children[0].before(ent);
}

function exAnnouncements() {
    GM_xmlhttpRequest({
        method: "post",
        url: 'https://ex124oj.netlify.app',
        headers: { "Content-Type": "application/x-www-form-urlencoded" },
        onload: function(r) {
            console.log(r);
        }
    });
}

function DiscussionCard() {
    var discrd = document.createElement('div');
    discrd.setAttribute('class', 'giscus');
    document.getElementsByClassName('uoj-footer')[0].before(discrd);
    var script = document.createElement('script');
    script.setAttribute('src', 'https://giscus.app/client.js');
    script.setAttribute('data-repo', 'Sukwants/Discuss124OJ');
    script.setAttribute('data-repo-id', 'R_kgDOImiZLA');
    script.setAttribute('data-category', 'Ideas');
    script.setAttribute('data-category-id', 'DIC_kwDOImiZLM4CTCIj');
    script.setAttribute('data-mapping', 'pathname');
    script.setAttribute('data-strict', '0');
    script.setAttribute('data-reactions-enabled', '1');
    script.setAttribute('data-emit-metadata', '0');
    script.setAttribute('data-input-position', 'top');
    script.setAttribute('data-theme', 'preferred_color_scheme');
    script.setAttribute('data-lang', 'zh-CN');
    script.setAttribute('crossorigin', 'anonymous');
    script.setAttribute('async', '');
    document.getElementsByTagName('body')[0].appendChild(script);
    GM_addStyle('\
.giscus {\
    margin-top: 20px;\
}');
}

const ManageStatementExp = /^.*\/manage\/statement(\?.*){0,1}$/
function CodeBlock() {
    GM_addStyle('\
@import url(https://cdn.jsdelivr.net/npm/[email protected]/distr/fira_code.css);\
code {\
    font-family: "Fira Code";\
}\
code.sh_cpp>span {\
    font-style: normal !important;\
    font-weight: 400 !important;\
}\
code.sh_cpp>span.sh_preproc,\
code.sh_cpp>span.sh_keyword,\
code.sh_cpp>span.sh_type {\
    color: #8959a8;\
}\
code.sh_cpp>span.sh_string {\
    color: #718c00;\
}\
code.sh_cpp>span.sh_cbracket {\
    color: #4d4d4c;\
}\
code.sh_cpp>span.sh_symbol {\
    color: #3e999f;\
}\
code.sh_cpp>span.sh_number {\
    color: #f5871f;\
}\
code.sh_cpp>span.sh_function {\
    color: #4271ae;\
}\
code.sh_cpp>span.sh_comment {\
    color: #8e908c;\
}\
.copybutton {\
    float: right;\
    background-color: rgb(0,0,0,.1);\
    padding: .25em .625em;\
    border: 0 solid transparent;\
    border-radius: .28571429rem;\
}\
.copybutton:hover {\
    background-color: rgb(0,0,0,.2);\
}\
.copybutton:focus {\
    background-color: rgb(0,0,0,.2);\
    outline: none;\
}');
    if (!ManageStatementExp.test(window.location.href)) {
        setTimeout(function(){
            var CodeBlocks = document.getElementsByTagName('pre');
            for (var cb in CodeBlocks) {
                if (CodeBlocks[cb] && CodeBlocks[cb].nodeType) {
                    var Content = CodeBlocks[cb].textContent;
                    var InputId = Math.round(Math.random() * 998244353);
                    var ButtonId = Math.round(Math.random() * 998244353);
                    CodeBlocks[cb].innerHTML = '<button class="copybutton" id = "' + ButtonId + '" onclick="\
var ib = document.getElementById(\'' + InputId + '\');\
ib.setAttribute(\'style\', \'display:initial\');\
ib.value = \'' + Content.replace(/\\/g, '\\\\').replace(/\n/g, '\\n').replace(/'/g, '\\&#39;').replace(/"/g, '&#34;') + '\';\
ib.select();\
document.execCommand(\'copy\');\
ib.setAttribute(\'style\', \'display:none\');\
var ic = document.getElementById(\'' + ButtonId + '\');\
ic.innerHTML = \'已复制\';\
setTimeout(function() { ic.innerHTML = \'复制\'; }, 500);">复制</button>' + CodeBlocks[cb].innerHTML;
                    var InputBox = document.createElement('textarea');
                    InputBox.setAttribute('id', InputId);
                    InputBox.setAttribute('style', 'display:none');
                    CodeBlocks[cb].appendChild(InputBox);
                }
            }

        }, 30);
    }
}

function NameColor() {
    var Names = document.getElementsByClassName('uoj-username');
    var NeedsRepeat = false;
    for (var i in Names) {
        if (Names[i].innerHTML && NameColorList[Names[i].innerHTML]) {
            Names[i].style = 'color:' + NameColorList[Names[i].innerHTML][0];
            var resN = '';
            for (var charN = 1; charN < NameColorList[Names[i].innerHTML].length; ++charN) {
                resN = resN + '<font style="color:' + NameColorList[Names[i].innerHTML][charN] + '">' + Names[i].innerHTML.substring(charN - 1, charN) + '</font>';
            }
            Names[i].innerHTML = resN + Names[i].innerHTML.substring(NameColorList[Names[i].innerHTML].length - 1);
            if (Names[i].parentElement.getAttribute('class') == 'legendLabel') {
                NeedsRepeat = true;
            }
        }
    }
    if (NeedsRepeat) {
        setInterval(function(){
            var Names = document.getElementsByClassName('uoj-username');
            for (var i in Names) {
                if (Names[i].innerHTML && Names[i].parentElement.getAttribute('class') == 'legendLabel' && NameColorList[Names[i].innerHTML]) {
                    Names[i].style = 'color:' + NameColorList[Names[i].innerHTML][0];
                    var resN = '';
                    for (var charN = 1; charN < NameColorList[Names[i].innerHTML].length; ++charN) {
                        resN = resN + '<font style="color:' + NameColorList[Names[i].innerHTML][charN] + '">' + Names[i].innerHTML.substring(charN - 1, charN) + '</font>';
                    }
                    Names[i].innerHTML = resN + Names[i].innerHTML.substring(NameColorList[Names[i].innerHTML].length - 1);
                }
            }
        }, 200);
    }
    var Honors = document.getElementsByClassName('uoj-honor');
    for (var j in Honors) {
        if (Honors[j].innerHTML && NameColorList[Honors[j].innerHTML]) {
            Honors[j].style = 'color:' + NameColorList[Honors[j].innerHTML][0];
            var resH = '';
            for (var charH = 1; charH < NameColorList[Honors[j].innerHTML].length; ++charH) {
                resH = resH + '<font style="color:' + NameColorList[Honors[j].innerHTML][charH] + '">' + Honors[j].innerHTML.substring(charH - 1, charH) + '</font>';
            }
            Honors[j].innerHTML = resH + Honors[j].innerHTML.substring(NameColorList[Honors[j].innerHTML].length - 1);
        }
    }
}

const NameExp = /^(.{1,}?)( .*){0,1}$/;
function CCFBadge() {
    var Names = document.getElementsByClassName('uoj-username');
    for (var i in Names) {
        if (!Names[i].innerHTML || !NameExp.test(Names[i].textContent)) continue;
        var name = Names[i].textContent.match(NameExp)[1];
        if (CCFBadgeList[name] && Names[i].parentElement.getAttribute('class') != 'legendLabel') {
            Names[i].innerHTML = Names[i].innerHTML + ' <svg width="1em" height="1em" data-v-303bbf52="" aria-hidden="true" focusable="false" data-prefix="fad" data-icon="badge-check" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="margin-bottom:.25em!important;bottom:10px;--fa-primary-color:#fff;--fa-secondary-color:' + CCFBadgeList[name] + ';--fa-secondary-opacity:1;"><g data-v-303bbf52="" class="fa-group"><path data-v-303bbf52="" fill="var(--fa-secondary-color)" d="M512 256a88 88 0 0 0-57.1-82.4A88 88 0 0 0 338.4 57.1a88 88 0 0 0-164.8 0A88 88 0 0 0 57.1 173.6a88 88 0 0 0 0 164.8 88 88 0 0 0 116.5 116.5 88 88 0 0 0 164.8 0 88 88 0 0 0 116.5-116.5A88 88 0 0 0 512 256zm-144.8-44.25l-131 130a11 11 0 0 1-15.55-.06l-75.72-76.33a11 11 0 0 1 .06-15.56L171 224a11 11 0 0 1 15.56.06l42.15 42.49 97.2-96.42a11 11 0 0 1 15.55.06l25.82 26a11 11 0 0 1-.08 15.56z" class="fa-secondary"></path></g></svg>';
        }
    }
    var Honors = document.getElementsByClassName('uoj-honor');
    for (var j in Honors) {
        if (!Honors[j].innerHTML || !NameExp.test(Honors[j].textContent)) continue;
        var honor = Honors[j].textContent.match(NameExp)[1];
        if (CCFBadgeList[honor]) {
            Honors[j].innerHTML = Honors[j].innerHTML + ' <svg width="1em" height="1em" data-v-303bbf52="" aria-hidden="true" focusable="false" data-prefix="fad" data-icon="badge-check" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="margin-bottom:.25em!important;bottom:10px;--fa-primary-color:#fff;--fa-secondary-color:' + CCFBadgeList[honor] + ';--fa-secondary-opacity:1;"><g data-v-303bbf52="" class="fa-group"><path data-v-303bbf52="" fill="var(--fa-secondary-color)" d="M512 256a88 88 0 0 0-57.1-82.4A88 88 0 0 0 338.4 57.1a88 88 0 0 0-164.8 0A88 88 0 0 0 57.1 173.6a88 88 0 0 0 0 164.8 88 88 0 0 0 116.5 116.5 88 88 0 0 0 164.8 0 88 88 0 0 0 116.5-116.5A88 88 0 0 0 512 256zm-144.8-44.25l-131 130a11 11 0 0 1-15.55-.06l-75.72-76.33a11 11 0 0 1 .06-15.56L171 224a11 11 0 0 1 15.56.06l42.15 42.49 97.2-96.42a11 11 0 0 1 15.55.06l25.82 26a11 11 0 0 1-.08 15.56z" class="fa-secondary"></path></g></svg>';
        }
    }
}
function TagBadge() {
    var Names = document.getElementsByClassName('uoj-username');
    for (var i in Names) {
        if (!Names[i].innerHTML || !NameExp.test(Names[i].textContent)) continue;
        var name = Names[i].textContent.match(NameExp)[1];
        if (TagBadgeList[name] && Names[i].parentElement.getAttribute('class') != 'legendLabel') {
            Names[i].innerHTML = Names[i].innerHTML + ' <span style="background-color:' + TagBadgeList[name][0] + ';padding:0.2em 0.6em;border-radius:.2em;color:#fff;font-size:0.7em;font-weight:bold;display:inline-block">' + TagBadgeList[name][1] + '</span>';
        }
    }
    var Honors = document.getElementsByClassName('uoj-honor');
    for (var j in Honors) {
        if (!Honors[j].innerHTML || !NameExp.test(Honors[j].textContent)) continue;
        var honor = Honors[j].textContent.match(NameExp)[1];
        if (TagBadgeList[honor]) {
            Honors[j].innerHTML = Honors[j].innerHTML + ' <span style="background-color:' + TagBadgeList[honor][0] + ';padding:0.2em 0.6em;border-radius:.2em;color:#fff;font-size:0.7em;font-weight:bold;display:inline-block">' + TagBadgeList[honor][1] + '</span>';
        }
    }
}

function TableStyle() {
    var Tables = document.getElementsByTagName('table');
    for (var table in Tables) {
        if (Tables[table].nodeType && Tables[table].parentNode.getAttribute('class') != 'legend' && !Tables[table].classList.length) {
            Tables[table].classList.add('table', 'table-bordered');
        }
    }
    var ths = document.getElementsByTagName('th');
    for (var th in ths) {
        if (ths[th].nodeType && ths[th].getAttribute('align')) {
            ths[th].setAttribute('style', 'text-align:' + ths[th].getAttribute('align'));
        }
    }
}

function SubmissionCard() {
    setTimeout(function() {
        var Content = document.getElementsByClassName('uoj-content')[0];
        if (Content.childElementCount == 3) {
            var Table = Content.children[0];
            var TabList = document.createElement('ul');
            TabList.setAttribute('class', 'nav nav-tabs');
            TabList.setAttribute('role', 'tablist');
            TabList.innerHTML = '<li class="nav-item"><a class="nav-link active" href="#test-cases" role="tab" data-toggle="tab" aria-selected="true"><span class="glyphicon glyphicon-check"></span> 测试点信息</a></li><li class="nav-item"><a class="nav-link" href="#source" role="tab" data-toggle="tab" aria-selected="false"><span class="glyphicon glyphicon-file"></span> 源代码</a></li>';
            var TabContent = document.createElement('div');
            TabContent.setAttribute('class', 'tab-content');
            TabContent.innerHTML = '<div class="tab-pane card active" id="test-cases"><div class="card-body">' + Content.children[2].children[1].innerHTML + '</div></div><div class="tab-pane card" id="source"><div class="card-body">' + Content.children[1].children[1].innerHTML + '</div></div>';
            Content.innerHTML = "";
            Content.appendChild(Table);
            Content.appendChild(TabList);
            Content.appendChild(TabContent);
        }
    }, 50);
}

function downloadData() {
    var DownloadTag = document.createElement('a');
    DownloadTag.setAttribute('role', 'button');
    DownloadTag.setAttribute('class', 'btn btn-primary float-right');
    DownloadTag.setAttribute('href', '/download.php?type=problem&id=' + window.location.href.match(ProblemRegExp)[1]);
    DownloadTag.setAttribute('target', '_blank');
    DownloadTag.innerHTML = '<span class="glyphicon glyphicon-download-alt"></span> 下载数据';
    document.getElementsByClassName("btn btn-info float-right")[0].after(DownloadTag);
}

const GravatarURLRegExp = /\/\/cn.gravatar.com\/avatar\/(.*)$/;
function changeGravatarURL() {
    var Gravatar = document.getElementsByClassName('img-thumbnail')[0];
    if (Gravatar && Gravatar.nodeType){
        console.log(Gravatar);
        Gravatar.setAttribute('src', '//gravatar.loli.net/avatar/' + Gravatar.getAttribute('src').match(GravatarURLRegExp)[1]);
    }
    var Gravatars = document.getElementsByClassName('img-rounded');
    for (var gravatar in Gravatars) {
        if (Gravatars[gravatar] && Gravatars[gravatar].nodeType && GravatarURLRegExp.test(Gravatars[gravatar].getAttribute('src'))) {
            Gravatars[gravatar].setAttribute('src', '//gravatar.loli.net/avatar/' + Gravatars[gravatar].getAttribute('src').match(GravatarURLRegExp)[1]);
        }
    }
}

(function() {
    'use strict';
    whenMourn();
    trollForAmusement()
    BackgroundImage();
    changeIcon();
    HomepageEntrance();
    exAnnouncements();
    DiscussionCard();
    CodeBlock();
    NameColor();
    CCFBadge();
    TagBadge();
    TableStyle();
    if (isSubmission()) SubmissionCard();
    if (isProblem()) downloadData();
    if (isUserProfile() || isBlog()) changeGravatarURL();
})();