Created
June 22, 2010 08:30
-
-
Save rummelonp/448179 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 Replace Full Images | |
// @namespace jp.mitukiii.twitpic | |
// @include http*://twitpic.com/photos/* | |
// ==/UserScript== | |
(function() { | |
Array.prototype.each = function(iterator) { | |
for (var i = 0; i < this.length; i += 1) { | |
iterator(this[i], i); | |
}; | |
return this; | |
}; | |
Array.prototype.first = function() { | |
return this[0]; | |
}; | |
var $A = function(args) { | |
var _args = []; | |
for (var i = 0; i < args.length; i += 1) { | |
_args.push(args[i]); | |
}; | |
return _args; | |
}; | |
var createFullImageUrl = function() { | |
var full_url = 'http://twitpic.com/show/full/'; | |
return function(uniq_id) { | |
return full_url + uniq_id; | |
}; | |
}(); | |
var replaceUrl = function(elem) { | |
var a = $A(elem.getElementsByTagName('a')).first(); | |
var uniq_id = a.href.match(/https?:\/\/twitpic.com\/(.+?)$/)[1]; | |
var img = $A(elem.getElementsByTagName('img')).first(); | |
var url = createFullImageUrl(uniq_id); | |
a.setAttribute('href', url); | |
img.setAttribute('src', url); | |
img.setAttribute('width', '150px'); | |
}; | |
$A(document.getElementsByClassName('profile-photo-img')).each(replaceUrl); | |
document.addEventListener('DOMNodeInserted', function(event) { | |
var elem = event.target; | |
if (elem.getAttribute('id') === 'image-') { | |
replaceUrl($A(elem.getElementsByClassName('profile-photo-img')).first()); | |
}; | |
}, false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment