Greasy Fork is available in English.

JOJ Simple Diff

Make your life easier when comparing the results in JOJ!

Stan na 22-10-2020. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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;
    }
})();