AF Clock

adds a PST clock to art fight's navbar

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         AF Clock
// @namespace    artfight
// @version      2025-06-23
// @description  adds a PST clock to art fight's navbar
// @author       three
// @match        *://artfight.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=artfight.net
// @grant        none
// @noframes
// ==/UserScript==

var clock = document.createElement('li');
clock.id = 'clock';
clock.className = "nav-link";
let navbar = document.querySelectorAll("ul.ml-auto")[0];
navbar.insertBefore(clock, navbar.firstChild);

function updateClock(){
    //get date in PST
        var currentTime = new Date(new Date().toLocaleString("en-US", {timeZone: "US/Pacific"}));
        var hours = currentTime.getHours();
        var minutes = currentTime.getMinutes();
    //format time with leading 0s
        minutes = minutes < 10 ? '0' + minutes : minutes;
        hours = hours < 10 ? '0' + hours : hours;

    // Update clock
    //console.log("update");
        clock.textContent = hours + ':' + minutes + " PST";
}

// Update clock every second
    setInterval(updateClock, 1000);