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.

当前为 2024-01-22 提交的版本,查看 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址