Last active
November 3, 2017 14:18
-
-
Save franga2000/e9fe898fb2f0efeaf284598dff6e216c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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