Skip to content

Instantly share code, notes, and snippets.

@ItsOnlyBinary
Created June 14, 2021 13:06
Show Gist options
  • Save ItsOnlyBinary/52a3b1197993d8ea67b11ec8833398ff to your computer and use it in GitHub Desktop.
Save ItsOnlyBinary/52a3b1197993d8ea67b11ec8833398ff to your computer and use it in GitHub Desktop.
<script>
kiwi.plugin('userbox_whois_geoip', function(kiwi, log) {
var currentUser = null;
kiwi.on('userbox.show', function (user, buffer) {
currentUser = user;
});
kiwi.on('sidebar.hide', function (user, buffer) {
currentUser = null;
});
kiwi.on('irc.whois', function (event, network, ircEventObj) {
if (event.nick !== currentUser.nick) {
return;
}
var userboxWhois = document.querySelector('.kiwi-userbox-whois');
if (!userboxWhois) {
// Whois not currently shown
return;
}
var userboxWhoisGeoip = userboxWhois.querySelector('.kiwi-whois-geoip');
if (userboxWhoisGeoip) {
// Dom element already exists
return;
}
if (!event.special || !event.special.geoip) {
// Whois does not have the data we are looking for
return;
}
var whoisGeoip = document.createElement('span');
whoisGeoip.className = 'kiwi-whois-geoip';
whoisGeoip.innerText = event.special.geoip;
userboxWhois.appendChild(whoisGeoip);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment