Skip to content

Instantly share code, notes, and snippets.

@ucnv
Forked from ucnv/show_panoid.user.js
Created October 29, 2009 12:59
Show Gist options
  • Save ucnv/221427 to your computer and use it in GitHub Desktop.
Save ucnv/221427 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Streetview Thumbnail
// @namespace http://userscripts.org/users/ucnv
// @include http://maps.google.tld/maps*
// @include http://www.google.tld/maps*
// ==/UserScript==
var zoom = 1; // 0-3
function makeLink(panoid) {
var mx = [[1, 1], [2, 1], [4, 2], [6, 4]];
var link = '<div style="white-space:nowrap;">';
for(var y = 0; y < mx[zoom][1]; y++) {
for(var x = 0; x < mx[zoom][0]; x++) {
link += '<img src="http://cbk3.google.com/cbk?output=tile&zoom='
+ zoom + '&panoid=' + panoid + '&x=' + x + '&y=' + y + '" />';
}
link += '<br/>'
}
link += '</div>'
return 'data:text/html;,' + encodeURIComponent(link);
}
document.getElementById('links') && (function() {
var thumb = document.createElement('div');
thumb.style.cssText = 'position:absolute;right:1px;top:25px;';
thumb.innerHTML = '<a href="" target="_blank" id="link-thumb"><img style="height:65px;" src="" /></a>';
var href = 'http://cbk3.google.com/cbk?output=thumbnail&panoid=';
document.getElementById('link').addEventListener('DOMAttrModified', function(e) {
if(e.attrName != 'href') return;
var m = e.target.href.match(/panoid=([^&]+)/);
if(!m) {
document.body.removeChild(thumb);
} else {
if(document.getElementById('link-thumb') == null) document.body.appendChild(thumb);
var target = document.getElementById('link-thumb');
target.childNodes[0].src = href + m[1];
target.href = makeLink(m[1]);
}
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment