Skip to content

Instantly share code, notes, and snippets.

@tsvetomir
Created March 15, 2012 15:59
Show Gist options
  • Save tsvetomir/2044945 to your computer and use it in GitHub Desktop.
Save tsvetomir/2044945 to your computer and use it in GitHub Desktop.
Local time in Campfire chats
// ==UserScript==
// @name Campfire local time
// @namespace http://tsonev.net/campfire/localtime
// @version 0.2
// @description Converts time stamps to local time in Campfire chats. Tested in Chrome.
// @match https://XXXXXX.campfirenow.com/room/*
// ==/UserScript==
var TIME_ZONE = "CDT";
function convertTimes() {
var dates = document.querySelectorAll(".date span");
var times = document.querySelectorAll(".time div");
for (var i = 0; i < dates.length; i++) {
if (!times[i]._converted) {
var timestamp = new Date(dates[i].innerHTML + " " + times[i].innerHTML + " " + TIME_ZONE);
times[i].innerHTML = timestamp.toLocaleTimeString();
times[i]._converted = true;
}
}
}
window.addEventListener("load", function(e) {
setInterval(convertTimes, 500);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment