Resolve audit log user IDs

This script calls the Jira user API, resolves user IDs in the Jira audit log and replaces them with the display names.

Pada tanggal 22 Januari 2024. Lihat %(latest_version_link).

// ==UserScript==
// @name         Resolve audit log user IDs
// @namespace    http://schuppentier.org/
// @version      2024-01-22
// @description  This script calls the Jira user API, resolves user IDs in the Jira audit log and replaces them with the display names.
// @author       You
// @match        https://*.atlassian.net/auditing/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=atlassian.net
// @grant        none
// @require      https://bowercdn.net/c/arrive-2.4.1/minified/arrive.min.js
// @license      MIT
// ==/UserScript==

/* jshint esversion: 8 */

(function() {
    'use strict';

    document.arrive("span.delta-from, span.delta-to", async (elem) => {
        const recordRow = elem.closest("tr.record-row-details").previousElementSibling;
        const summary = recordRow.querySelector("td.summary").innerText;
        if (summary != "Project roles changed") {
            return;
        }

        const userIds = elem.innerText.split(",").map(item => item.trim());
        const userNames = await Promise.all(userIds.map(async (userId) => {
            const userResponse = await fetch(`/rest/api/3/user?accountId=${userId}`);
            const userObject = await userResponse.json();
            const userDisplayName = userObject.displayName;
            return userDisplayName;
        }));
        elem.innerText = userNames.join(", ");
    });
})();