Skip to content

Instantly share code, notes, and snippets.

@franga2000
Last active November 3, 2017 14:18
Show Gist options
  • Save franga2000/e9fe898fb2f0efeaf284598dff6e216c to your computer and use it in GitHub Desktop.
Save franga2000/e9fe898fb2f0efeaf284598dff6e216c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name WiGLE MAC address manufacturer lookup
// @namespace com.franga2000
// @downloadUrl https://gist.githubusercontent.com/franga2000/e9fe898fb2f0efeaf284598dff6e216c/raw/GM_WiGLE_OUI.js
// @match https://wigle.net/mapsearch*
// @run-at document-idle
// @grant none
// ==/UserScript==
function loadTitle(el) {
var req = new XMLHttpRequest();
req.open("GET", "https://api.macvendors.com/" + el.innerHTML);
req.onload = function() {
if (req.status == 200) {
el.title = req.response;
}
};
req.send(null);
}
var selector = "#resultColumn .mapsearchResult .mapsearchInnerTable tr:nth-child(2) td:nth-child(1) strong";
function init() {
document.querySelectorAll(selector).forEach(function(el) {
el.onmouseover = function() {
if (el.title == "") {
el.title = "Loading...";
loadTitle(el);
}
};
});
}
var target = document.getElementById('resultColumn');
var observer = new MutationObserver(init);
observer.observe(document.getElementById("resultColumn"), { attributes: false, childList: true, characterData: false });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment