This made me so frustrated, I fixed it with a tampermonkey script…
It would likely have been easier, if your code is open sourced.
This is not the best code, but works.
In case you are interested.
// ==UserScript==
// @name Rachio Reorder Calendar
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Rachio Reorder Calendar
// @author Duane May
// @match https://app.rach.io/locations/*/devices/*
// @match https://app.rach.io/devices/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=rach.io
// @grant none
// @run-at document-idle
// ==/UserScript==
function getDaysArray() {
let daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var dates = new Array();
dates.push("Today");
var date = new Date();
for (var i = 1; i < 7; i++) {
date.setDate(date.getDate() + 1);
let dayOfWeek = date.getDay();
dates.push(daysOfWeek[dayOfWeek]);
}
for (i = 1; i < 9; i++) {
date.setDate(date.getDate() + 1);
let formattedDate = (date.getMonth() + 1).toString().padStart(2, '0') + '/' +
date.getDate().toString().padStart(2, '0');
dates.push(formattedDate);
}
return dates;
}
function main() {
console.log("Reordering dates");
var sections = document.getElementsByClassName("test-location-schedule-container")
if (sections.length == 0) {
return;
}
var childrenOfSection = sections[0].childNodes;
if (childrenOfSection.length == 0) {
return;
}
var div = childrenOfSection[1].childNodes;
if (div.length == 0) {
return;
}
var container = div[0];
var dates = getDaysArray();
var newOrder = new Array(dates.length);
var childDivs = container.childNodes;
for (var i = 0; i < childDivs.length; i++) {
var childDiv = childDivs[i];
var divs = childDiv.getElementsByTagName('div');
if (divs.length == 0) {
continue;
}
sections = divs[0].getElementsByTagName('section');
if (sections.length == 0) {
continue;
}
divs = sections[0].getElementsByTagName('div');
if (divs.length == 0) {
continue;
}
var dateDiv = divs[0];
var matchValue = dateDiv.innerHTML
var index = dates.indexOf(matchValue);
newOrder[index] = childDiv;
}
for (i = newOrder.length; i >= 0; i--) {
if (newOrder[i] == null) {
continue;
}
console.log(dates[i]);
container.insertBefore(newOrder[i], container.firstChild);
}
}
(function() {
'use strict';
window.addEventListener('load', (event) => {
console.log('The page has fully loaded');
setTimeout(function() {
main();
}, 3000);
});
})();