H3C eos日志格式

修改H3C的eos日志字体为等宽字体

目前為 2024-02-21 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         H3C eos日志格式
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  修改H3C的eos日志字体为等宽字体
// @author       z404p
// @match        *://eos.h3c.com/project/logs*
// @match        *://eos-ts.h3c.com/project/logs*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
// @grant        GM_log
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var t = setInterval(function(){
        if(document.getElementById("loghtml")){
            var elementStyle = document.getElementById("loghtml").style
            elementStyle['font-family'] = 'Consolas'
            elementStyle['letter-spacing'] = '0'
            clearInterval(t);
        }
    }, 100);

    var pNum=0
    var t2 = setInterval(function(){
        if(document.getElementById("loghtml")){
            var element = document.getElementById("loghtml")
            if(pNum !== element.children.length){
                console.log(element.children.length)
                pNum = element.children.length
                editChildren(element)
            }
        }
    }, 100);

    function editChildren(element){
        for (let i = 0; i < element.children.length; i++) {
            var children = element.children[i];
            children.style['margin-bottom'] = '5px'
            children.style['word-break'] = 'break-word'
            if(children.innerHTML.includes(' ERROR')){
                children.style.color = 'red'
            }else if(children.innerHTML.includes(' WARN')){
                children.style.color = '#92d900'
            }else if(children.innerHTML.includes(' DEBUG')){
                children.style.color = '#959595'
            }
        }
    }
})();