Web-Scrape D-Link Internal IP/Name/MAC For Currently Connected Devices

This is for network admins.


var arr         = document.querySelectorAll('[id^="lan_computers_container"] tbody td').map(function(element){return element;}) //normalize NodeList to plain Array.
   ,ip_to_name  = {}
   ,ip_to_mac   = {}
   ,name_to_ip  = {}
   ,name_to_mac = {}
   ,mac_to_ip   = {}
   ,mac_to_name = {}
   ,i           = 0
   ,len         = arr.length
   ,ip
   ,name
   ,mac
   ;

for(i; i<len - 3; i+=3){
  ip   = arr[i];
  name = arr[i+1];
  mac  = arr[i+2];
  
  ip_to_name[ip]    = name;
  ip_to_mac[ip]     = mac;
  name_to_ip[name]  = ip;
  name_to_mac[name] = mac;
  mac_to_ip[mac]    = ip;
  mac_to_name[mac]  = name;
}

console.log(
  ip_to_name
 ,ip_to_mac
 ,name_to_ip
 ,name_to_mac
 ,mac_to_ip
 ,mac_to_name
)

This code will populate all of the connected devices, from http://192.168.0.1/Status/Device_Info.shtml,
in a way the it can be reused in information-pages such as http://192.168.0.1/Status/Logs.shtml,
http://192.168.0.1/Status/Internet_Sessions.shtml, http://192.168.0.1/Status/Wireless.shtml, http://192.168.0.1/Status/WISH_Sessions.shtml,…
or configuration pages such as http://192.168.0.1/Advanced/MAC_Address_Filter.shtml,…

With relatively few steps it can provide a way to quickly identify machines by verbose-name,
given previously by the admin.