-
-
Save ucnv/221427 to your computer and use it in GitHub Desktop.
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 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