Created
September 26, 2012 12:40
-
-
Save tarao/3787787 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 picasa_link_to_original | |
// @namespace http://orezdnu.org/ | |
// @description Make link to the original image | |
// @include https://picasaweb.google.com/* | |
// @include http://picasaweb.google.com/* | |
// @version 1 | |
// @grant | |
// ==/UserScript== | |
(function (w, d) { | |
w.addEventListener('load', function () { | |
var parentClass = 'goog-icon-list-icon-img-container'; | |
var imgs = d.getElementsByTagName('img'); | |
var subst = '/IMG_'; | |
var regexp = new RegExp('/s[0-9]+'+subst); | |
subst = '/d' + subst; | |
for (var i=imgs.length-1; 0 <= i; i--) { | |
if (imgs[i].parentNode.className == parentClass) { | |
var img = imgs[i]; | |
var src = img.src.replace(regexp, subst); | |
var a = d.createElement('a'); | |
var label = d.createTextNode('original'); | |
a.href = src; | |
a.style.fontSize = '12px'; | |
a.appendChild(label); | |
img.parentNode.insertBefore(a, img); | |
} | |
} | |
}); | |
})(window, document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment