Last active
August 29, 2015 14:13
-
-
Save andrewshadura/45026a8556ecb9c13de2 to your computer and use it in GitHub Desktop.
OpenStreetMap links on Facebook
This file contains 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 OpenStreetMap on Facebook | |
// @namespace [email protected] | |
// @include *://*.facebook.com/* | |
// @version 1 | |
// @grant none | |
// | |
// ==/UserScript== | |
var f = (function () { | |
var regex = /cp=([0-9.-]+)\\u00257E([0-9.-]+)&/; | |
var links = document.querySelectorAll("a[onmouseover *= 'bing.com\\\\/maps\\\\/']"); | |
var maps = []; | |
for (var i in links) { | |
if (links[i].onmouseover) { | |
var fn = links[i].onmouseover.toString(); | |
console.log("l: "+fn); | |
var match = fn.match(regex); | |
var url = "http://www.openstreetmap.org/?mlat=" + match[1] + "&mlon=" + match[2] + "#map=16/" + match[1] + "/" + match[2]; | |
console.log(url); | |
if (links[i].querySelector("img[src *= 'virtualearth']")) { | |
var id = "fbosmmap_" + Date.now() + "_" + i; | |
//links[i].innerHTML="<div id='" + id + "'></div>"; | |
maps.push(id); | |
} | |
links[i].onmouseover=function () {}; | |
links[i].onclick=function () {}; | |
links[i].href = url; | |
} | |
} | |
}); | |
var d = (function () { | |
f(); | |
setTimeout(d, 5000); | |
}); | |
f(); | |
setTimeout(function () { | |
d(); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment