hephaes git log

hephaes-显示Git提交记录

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         hephaes git log
// @namespace    http://tampermonkey.net/
// @version      0.0.4-beta
// @description  hephaes-显示Git提交记录
// @author       junliang.li
// @match        http://hephaes.idc1.fn/
// @grant        none
// @run-at       document-end
// @license      Apache 
// ==/UserScript==

(function () {
    "use strict";
    setTimeout(addBtn, 888);

    function addBtn() {
        let ele = document.querySelector("#bs-example-navbar-collapse-1 > ul");
        let btn = document.createElement("button");
        btn.innerHTML = "显示提交日志";
        btn.addEventListener("click", click);
        btn.setAttribute("style", "margin-top: 12px; margin-left: 10px");
        let parent = ele.parentNode;
        parent.insertBefore(btn, ele);
    }

    function click() {
        let existList = document.querySelectorAll(".tempEle");
        if (existList?.length) {
            existList.forEach(element => element.remove());
        }
        let element = document.querySelector("body > div.ng-scope > div:nth-child(2) > div > div > span:nth-child(1) > span");
        if (!element) {
            return;
        }
        let logList = angular
            ?.element(document.querySelector("[ng-controller=LogListCtrl]"))
            ?.scope()
            ?.detail
            ?.log
            ?.list;
        if (!logList?.length) {
            return;
        }
        let trList = document.querySelectorAll("body > div.ng-scope > div:nth-child(2) > div > table > tbody >tr");
        if (!trList?.length) {
            return;
        }
        for (let i = 0; i < trList.length; i++) {
            let logStr = logList[i]?.info?.console?.[0];
            let msg = "";
            if (logStr?.includes("Commit message")) {
                let reg = /(?<=timeout=10\nCommit\smessage:\s).*/;
                msg = reg.exec(logStr)?.[0]?.slice(1, -1)?.trim() ?? "";
            }
            let gitLogTd = document.createElement("td");
            gitLogTd.setAttribute("class", "tempEle");
            gitLogTd.setAttribute("style", "width: 30%");
            gitLogTd.innerHTML = msg;
            trList[i].appendChild(gitLogTd);
        }

    }
})();