Github Comment显示24小时时间(仅适用国内用户-北京时间)

github的comment默认显示英语日期,此脚本自动转换为北京时间24小时计时法

目前为 2021-02-28 提交的版本。查看 最新版本

// ==UserScript==
// @name         Github Comment显示24小时时间(仅适用国内用户-北京时间)
// @name:en      Github Comment English Time to GTM8 (Beijing)
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  github的comment默认显示英语日期,此脚本自动转换为北京时间24小时计时法
// @description:en github comment default shows English date without time, this script replace it as GTM8(Beijing time) 24h time
// @homepage     https://gf.qytechs.cn/zh-CN/scripts/422423
// @icon         https://github.com/fluidicon.png
// @author       tumuyan
// @match        https://github.com/*/commits/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.querySelectorAll(`.TimelineItem-body`).forEach((item) => {
        var t = item.querySelector(`relative-time`).title.toString();
        t = t.replace("年","-").replace("月","-").replace("日","").replace("GMT+8","").replace(" 上午","");

        if(t.indexOf("下午")>0){
            t=t.replace("下午0","下午")
                .replace(" 下午0:","12:")
                .replace(" 下午1:","13:")
                .replace(" 下午2:","14:")
                .replace(" 下午3:","15:")
                .replace(" 下午4:","16:")
                .replace(" 下午5:","17:")
                .replace(" 下午6:","18:")
                .replace(" 下午7:","19:")
                .replace(" 下午8:","20:")
                .replace(" 下午9:","21:")
                .replace(" 下午10:","22:")
                .replace(" 下午11:","23:")
                .replace(" 下午12:","24:");
        }

        // var t= "2020年11月9日 GMT+8 下午11:00".replace("年","-").replace("月","-").replace("日","").replace("GMT+8","");
        item.querySelector(`h2`).innerText=t;
        //        console.log(item.text);
    });
    //$('.TimelineItem-body').click(function () {   });
})();

QingJ © 2025

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