Skip to content

Instantly share code, notes, and snippets.

@andrewshadura
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewshadura/45026a8556ecb9c13de2 to your computer and use it in GitHub Desktop.
Save andrewshadura/45026a8556ecb9c13de2 to your computer and use it in GitHub Desktop.
OpenStreetMap links on Facebook
// ==UserScript==
// @name OpenStreetMap on Facebook
// @namespace andrew@shadura.me
// @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