Right now, we can only see 5 rows of DHCP leases on settings.php?tab=piholedhcp
. This Userscript changes it to show all records both on Currently active
and Static
leases tables.
I'm also making a link on the host name that opens a MAC finder service showing what kind of device is that.
You have to adjust the IP of your PiHole at the beginning. The MAC finder provider can be changed adjusting the URL (I'm not affiliated to this one); and noting that I'm using only the first 3 hex numbers to build the search URL.
// ==UserScript==
// @name PiHole
// @version 0.1
// @description lil' mods
// @icon http://192.168.1.152/admin/img/favicon.png
// @match http://192.168.1.152/admin/settings.php*
// @require https://code.jquery.com/jquery-3.4.1.slim.min.js
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
/* Sets link to service provider */
let goMACFinder = function( host, spm ) {
let href = `https://www.ipchecktool.com/tool/macfinder?oui=${spm[0]}%3A${spm[1]}%3A${spm[2]}&page=1`;
host.html( `<a href="${href}" target="_blank">${host.text()}</a>` );
};
let buildMACActive = function(){
let mac = $(this).find('td#MAC').text(),
host = $(this).find('td#HOST'),
spm = mac.split(':');
goMACFinder( host, spm );
};
let buildMACStatic = function(){
let mac = $(this).find('td:nth-of-type(1)').text(),
host = $(this).find('td:nth-of-type(3)'),
spm = mac.split(':');
goMACFinder( host, spm );
};
/* Do the modifications */
let doMods = function() {
GM_addStyle('.dataTables_scrollBody { max-height:none !important; }');
$("#DHCPLeasesTable tr").each( buildMACActive );
$('#DHCPStaticLeasesTable tr').each( buildMACStatic );
};
/* Waits the right tab to be loaded */
let doMutationObs = function() {
let mCallback = function(mutations) {
if( window.location.search == '?tab=piholedhcp' ) {
doMods();
observer.disconnect();
}
};
let mPar = document.getElementsByClassName('tab-content')[0],
options = {
attributes: true,
subtree: true,
attributeFilter: ['class']
},
observer = new MutationObserver(mCallback);
observer.observe(mPar, options);
};
if( window.location.search != '?tab=piholedhcp' ) doMutationObs();
else doMods();
})();