Skip to content

Instantly share code, notes, and snippets.

@tcoliver
Last active March 5, 2020 13:42
Show Gist options
  • Select an option

  • Save tcoliver/ee3bf76847e5fd87cc251e1f5c707bec to your computer and use it in GitHub Desktop.

Select an option

Save tcoliver/ee3bf76847e5fd87cc251e1f5c707bec to your computer and use it in GitHub Desktop.
A simple Tampermonkey script for adding auto-refresh to a TeamDynamix Desktop. This script refreshes each modules individually, so the page does not need to be reloaded. In order to use, install the Tampermonkey extension from https://tampermonkey.net/ and import the script.
// ==UserScript==
// @name TeamDynamix Desktop AutoRefresh
// @namespace https://www.teamdynamix.com/
// @version 1.0.1
// @description Refresh TDX desktop modules without reloading the page.
// @author tcoliver
// @match */TDNext/Home/Desktop/Default.aspx*
// @grant none
// ==/UserScript==
setInterval(refDesk, 15000);
function getIds() {
var rows = document.getElementById('appDesktop').contentDocument.getElementsByClassName('row');
var cols;
var items;
var mods = [];
var i;
var j;
var k;
for (i=0; i < rows.length; i++) {
cols = rows[i].children;
for (j=0; j < cols.length; j++) {
items = cols[j].children;
for (k=0; k < items.length; k++) {
mods.push(Number(items[k].id));
}
}
}
return mods;
}
function refDesk() {
var ids = getIds();
var n;
for (n=0; n<ids.length; n++) {
document.getElementById('appDesktop').contentWindow.refreshModule(ids[n]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment