In [3]:
from urllib.parse import unquote
In [2]:
bookmarklet = \
"""
javascript:(function()%20%7Bvar%20d%3Ddocument,w%3Dwindow,l%3Dd.location.href%3Blats%3Dl.indexOf(%27!2d%27)%2B3%3Blate%3Dl.indexOf(%27!3d%27,lats)%3Blat%3Dl.substring(lats,late)%3Blngs%3Dl.indexOf(%27!3d%27)%2B3%3Blnge%3Dl.indexOf(%27!%27,lngs)%3Blnge%3D%3D-1%3Flnge%3Dl.length:lnge%3Dlnge%3Blng%3Dl.substring(lngs,lnge)%3Bw.open(%27http://demographics.coopercenter.org/DotMap/index.html%23lat%3D%27%20%2Blng%20%2B%20%27%26lon%3D%27%20%2B%20lat%20%2B%20%27%26z%3D12%27)%3B%7D)()
"""
In [5]:
print (unquote(bookmarklet))
In [42]:
script = """
javascript:(
function() {
var d = document,
w = window,
l = d.location.href;
parts = l.split("/");
for (i=0; i < parts.length; i++ ) {
p = parts[i];
if (p.startsWith("@")) {
c = p.substring(1).split(",");
c[2] = c[2].substring(0,c[2].length-1);
w.open("http://demographics.coopercenter.org/DotMap/index.html#lat=" +
c[0] + "&lon=" + c[1] + "&z=" + c[2]);
}
}
})()
"""
In [43]:
print (" ".join(script.split()))
In [24]:
bookmarklet = \
"""
javascript:(function() %7Bwindow.open("http://maps.google.com%3Fq%3D" %2Bmap.getCenter().lat() %2B "," %2B map.getCenter().lng())%3B%7D)()
"""
In [25]:
print (unquote(bookmarklet))
In [26]:
# https://www.google.com/maps/@37.868604,-122.2585271,17z
In [29]:
script = """
javascript:(
function() {
window.open("https://www.google.com/maps/@" +
map.getCenter().lat() + "," +
map.getCenter().lng() + "," +
map.getZoom() + "z");
})()
"""
In [30]:
print (" ".join(script.split()))
In [36]:
# http://demographics.coopercenter.org/DotMap/index.html#lat=33.6670191&lon=-117.7646826&z=10
script = """
javascript:(
function() {
var l = "http://demographics.coopercenter.org/DotMap/index.html" +
"#lat=" + map.getCenter().lat() +
"&lon=" + map.getCenter().lng() +
"&z=" + map.getZoom();
document.location = l;
})()
"""
In [37]:
print (" ".join(script.split()))
In [ ]: