Created
April 12, 2023 05:34
-
-
Save vanadium23/b18b7e9a9efafe625cc1c12653407b79 to your computer and use it in GitHub Desktop.
Tampermonkey script to view "office" time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Second timezone for Slack web client | |
// @namespace http://vanadium23.me/ | |
// @version 0.1 | |
// @description Add second time on element hover | |
// @author vanadium23 | |
// @match https://app.slack.com/client/* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// set your targetTimezone different from local | |
const targetTimezone = 'Europe/Belgrade'; | |
document.body.addEventListener('mouseover', (event) => { | |
if (event.target.classList.contains('c-timestamp__label')) { | |
let localTime = event.target.innerText; | |
if (localTime.indexOf('/') !== -1) { | |
// already converted | |
return; | |
} | |
const parentNode = event.target.parentNode; | |
const timestamp = parseInt(parentNode.dataset.ts)*1000; | |
const localDateTime = new Date(timestamp); | |
const targetTime = new Intl.DateTimeFormat('en-US', { | |
timeZone: targetTimezone, | |
hour: '2-digit', | |
minute: '2-digit', | |
hour12: false, | |
timeZoneName: "shortGeneric", | |
}).format(localDateTime); | |
event.target.innerText = `${localTime} / ${targetTime}`; | |
} | |
}); | |
})(); |
Author
vanadium23
commented
Apr 12, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment