Skip to content

Instantly share code, notes, and snippets.

@kerbeh
Last active November 21, 2017 04:37
Show Gist options
  • Save kerbeh/64fcf2bbd5717c2b0359961e3bf156ff to your computer and use it in GitHub Desktop.
Save kerbeh/64fcf2bbd5717c2b0359961e3bf156ff to your computer and use it in GitHub Desktop.
Echo360 ESS Device Room and IP config builder Bookmarklet
//Scrape the rooms and IPs from the page
var ips = [...document.querySelectorAll("a[id^='deviceUiLink']")].map(IP => `${IP.text}`);
var rooms = [...document.querySelectorAll("a[id^='showLink']")].map(Room => `${Room.text}`);
//Declare some containers to hold the data
var configArray = {};
var alertString = "";
//Loop over the IPs and add the matching room
var count = 0;
for (ip of ips) {
configArray[rooms[count].trim()] = ip;
alertString += '"' + rooms[count].trim() + '"' + "=>" + '"' + ip + '"' + ",\n";
count++;
}
//Output the results to the console and an alert box
console.log(configArray);
alert(alertString);
@kerbeh
Copy link
Author

kerbeh commented Nov 21, 2017

This JS gist is designed to be used as a bookmarklet and run on the Echo360 ESS ListRooms.html page.
It will scrape the page and build an array of Room => IP values.
This array can be used as the config file for https://github.com/kerbeh/echo360-monitor

The bookmarklet is encoded below, Usage Instructions are:

Drag it to your bookmarks toolbar
Rename the new bookmark
navigate to your EchoESS ListRooms.html page
Click the bookmarklet.
Repeat for every paginated page of rooms.

javascript:(function()%7Bvar%20ips%20%3D%20%5B...document.querySelectorAll(%22div.network%20span.type%22)%5D.map(IP%20%3D%3E%20%60%24%7BIP.textContent%7D%60)%3Bvar%20rooms%20%3D%20%5B...document.querySelectorAll(%22div.roomName%22)%5D.map(Room%20%3D%3E%20%60%24%7BRoom.textContent%7D%60)%3Bvar%20configArray%20%3D%20%7B%7D%3Bvar%20alertString%20%3D%20%22%22%3Bvar%20count%20%3D%200%3Bfor%20(ip%20of%20ips)%20%7BconfigArray%5Brooms%5Bcount%5D.trim()%5D%20%3D%20ip%3BalertString%20%2B%3D%20'%22'%20%2B%20rooms%5Bcount%5D.trim()%20%2B%20'%22'%20%2B%20%22%3D%3E%22%20%2B%20'%22'%20%2B%20ip%20%2B%20'%22'%20%2B%20%22%2C%5Cn%22%3Bcount%2B%2B%3B%7Dconsole.log(configArray)%3Balert(alertString)%7D)()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment