Instant Diffs

Instant Diffs is a JavaScript tool that enhances MediaWiki diff links with interactive functionality — dynamically loaded content via AJAX technology in dialog windows.

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

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

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         Instant Diffs
// @namespace    https://www.mediawiki.org/wiki/Instant_Diffs
// @version      1.1.1
// @description  Instant Diffs is a JavaScript tool that enhances MediaWiki diff links with interactive functionality — dynamically loaded content via AJAX technology in dialog windows.
// @author       Serhio Magpie
// @license      MIT
// @match        https://*/*
// @icon         https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Instant_Diffs_logo.svg/64px-Instant_Diffs_logo.svg.png
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-start
// ==/UserScript==

/* jshint esversion: 8 */

( ( window ) => {
    'use strict';

    /**
     * Semantic Versioning Comparing
     * @see {@link https://gist.github.com/iwill/a83038623ba4fef6abb9efca87ae9ccb}
     * @see {@link https://semver.org/}
     * @see {@link https://stackoverflow.com/a/65687141/456536}
     * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options}
     */
    function semverCompare( a, b ) {
        if ( a.startsWith( b + '-' ) ) return -1;
        if ( b.startsWith( a + '-' ) ) return 1;
        return a.localeCompare( b, undefined, { numeric: true, sensitivity: 'case', caseFirst: 'upper' } );
    }

    window.RLQ = window.RLQ || [];
    window.RLQ.push( () => {
        if ( typeof window.mw === 'undefined' ) return;

        window.mw.loader.enqueue( [ 'mediawiki.base' ], () => {
            const minimumVersion = '1.35';
            const currentVersion = window.mw.config.get( 'wgVersion' );
            if ( semverCompare( currentVersion, minimumVersion ) < 0 ) {
                console.error( `Instant Diffs: requires MediaWiki ${ minimumVersion }+, got ${ currentVersion }.` );
                return;
            }

            window.instantDiffs = window.instantDiffs || {};
            window.instantDiffs.GM = GM;

            window.mw.loader.getScript( 'https://www.mediawiki.org/w/index.php?title=User:Serhio_Magpie/instantDiffs.js&instantdiffs[GM]=true&action=raw&ctype=text/javascript' )
                .then( () => {
                    console.info( `Instant Diffs: loaded successfully.` );
                }, ( error ) => {
                    console.error( `Instant Diffs: loading failed: ${ error.message }.` );
                } );
        } );
    } );
} ) ( window.unsafeWindow );