Jira history diff

Highliht diff in Jira issue history.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Jira history diff
// @version      2025-11-12
// @description  Highliht diff in Jira issue history.
// @author       vctls
// @match        https://*.atlassian.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=atlassian.net
// @grant        none
// @require      https://cdn.jsdelivr.net/gh/google/diff-match-patch@62f2e689f498f9c92dbc588c58750addec9b1654/javascript/diff_match_patch_uncompressed.js
// @license      MIT
// @namespace    https://greasyfork.org/users/299396
// ==/UserScript==

(function() {
    'use strict';

    const handleMessage = () => {

        // Get all history entries that have description changes.
        // TODO Find a more reliable selector.
        const descChanges = document.querySelectorAll('[data-testid="issue-history.ui.history-items.generic-history-item.history-item"] >:nth-child(2):has(div:nth-child(1) > ._1reo1wug) ._1e0c1txw');

        descChanges.forEach((element, index) => {
            if (element.dataset.diffed) return;
            const right = element.querySelector('._syazi7uo:nth-of-type(1) ._1reo1wug');
            // nth-of-type(2) is the arrow icon between left and right items
            const left = element.querySelector('._syazi7uo:nth-of-type(3) ._1reo1wug');

            if (!left || !right) return;
            element.style.display = "block";
            const dmp = new diff_match_patch();
            const diff = dmp.diff_main(right.innerText, left.innerText);
            dmp.diff_cleanupSemantic(diff);
            element.innerHTML = dmp.diff_prettyHtml(diff);
            element.dataset.diffed = true;
        });
    };

    let timeoutId;
    const delayedHandler = () => {
        clearTimeout(timeoutId);
        timeoutId = setTimeout(() => handleMessage(), 10);
    };

    (new MutationObserver(delayedHandler)).observe(document, {childList: true, subtree: true});

})();