the100 24h format

12h to 24h format converter

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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;

    }


})();