the100 24h format

12h to 24h format converter

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         the100 24h format
// @namespace    https://www.the100.io/
// @version      0.1
// @description  12h to 24h format converter
// @author       Fryde
// @match        https://www.the100.io/*
// @grant        none
// ==/UserScript==

(function() {

    var times = document.getElementsByClassName('game-time');

    for ( i=0; i<times.length; i++) {

        var old = times[i].innerHTML;

        var regex = /([01]?\d)(:\d{2}) (AM|PM)/ig;
        var match = regex.exec(old);

        //12:00 -> 00:00
        match[1] = match[1]%12;
        //add 12h for pm
        if( match[3] == "PM" || match[3] == "pm") match[1] += 12;
        //add leading 0 if needed
        if( match[1] < 10) match[1] = "0"+match[1];

        times[i].innerHTML = old.replace(regex, match[1] + match[2] + ' Uhr');
        //add old time to title attribute
        times[i].title=old;

    }


})();