JOJ Simple Diff

Make your life easier when comparing the results in JOJ!

Verze ze dne 22. 10. 2020. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         JOJ Simple Diff
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Make your life easier when comparing the results in JOJ!
// @author       BoYanZh
// @match        https://joj.sjtu.edu.cn/d/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    String.prototype.rstrip = function() {
        return String(this).replace(/\s+$/g, '');
    };
    var stdout = document.querySelector("#stdout > div.section__body > pre");
    var answer = document.querySelector("#answer > div.section__body > pre");
    var stdoutTexts = stdout.textContent.split("\n");
    var answerTexts = answer.textContent.split("\n");
    for(var index1 = 0, index2 = 0; index1 < stdoutTexts.length && index2 < answerTexts.length;){
        if(answerTexts[index2].rstrip() !== stdoutTexts[index1].rstrip()){
            stdout.innerHTML = stdout.textContent.replace(stdoutTexts[index1], '<span style="background:red;">' + stdoutTexts[index1] + '</span>');
            --index1;
        }
        ++index1;++index2;
    }
})();