AF Clock

adds a PST clock to art fight's navbar

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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);