Skip to content

Instantly share code, notes, and snippets.

@dbaynard
Created October 22, 2021 13:17
Show Gist options
  • Save dbaynard/336d27d7c1ffa9b0582eca75e77d8145 to your computer and use it in GitHub Desktop.
Save dbaynard/336d27d7c1ffa9b0582eca75e77d8145 to your computer and use it in GitHub Desktop.
Convert CMS2021 schedule to local time
// ==UserScript==
// @name Convert CMS2021 Schedule to Local Time
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Convert CMS2021 schedule to local time
// @author David Baynard
// @match https://cms21.io/agenda/
// @icon https://www.google.com/s2/favicons?domain=cms21.io
// @grant none
// ==/UserScript==
(function() {
'use strict';
const convertScheduleToLocalTime = () =>
// Find schedule
[...document.querySelectorAll("div.elementor-widget-container")]
.filter((el) => !!el.querySelector("h5 > strong"))
.forEach((day) => {
// Extract the date for use in `Date.parse`
const date = `${day.querySelector("h5 > strong").innerHTML} 2021`;
[...day.children].forEach((el) => {
el.innerText = el.innerText.replace(
/^1?[0-9]:[0-5][0-9] [AP]M/,
(original_time) =>
new Date(Date.parse(`${date} ${original_time} PDT`))
.toTimeString()
// Extract 'HH:MM'
.split(":", 2)
?.join(":")
);
});
});
convertScheduleToLocalTime();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment