Skip to content

Instantly share code, notes, and snippets.

@saitamanodoruji
Created October 5, 2010 22:58
Show Gist options
  • Save saitamanodoruji/612508 to your computer and use it in GitHub Desktop.
Save saitamanodoruji/612508 to your computer and use it in GitHub Desktop.
Tumblr Dashboard High-Res Photos
// ==UserScript==
// @id Tumblr Dashboard High-Res Photos
// @name Tumblr Dashboard High-Res Photos
// @version 0.0.14.9
// @update 2013-06-11
// @namespace http://cxx.tumblr.com/
// @include http://www.tumblr.com/dashboard*
// @include http://www.tumblr.com/show/*
// @include http://www.tumblr.com/likes/*
// @include http://www.tumblr.com/liked/by/*
// @include http://www.tumblr.com/tagged/*
// @include http://www.tumblr.com/blog/*
// @run-at document-end
// @contributer taizooo https://gist.github.com/taizooo/635884
// @contributer saitamanodoruji https://gist.github.com/saitamanodoruji/612508
// @updateURL https://gist.github.com/saitamanodoruji/612508/raw/tumblr_dashboard_high-re.user.js
// @downloadURL https://gist.github.com/saitamanodoruji/612508/raw/tumblr_dashboard_high-re.user.js
// ==/UserScript==
// origin: http://userscripts.org/scripts/review/43621 by cxx
(function() {
function highRes(li) {
var img = li.querySelector('.image'),
postMedia = li.querySelector('.post_media'),
nextElem = li.querySelector('.post_body') || li.querySelector('.post_tags') || li.querySelector('.post_footer'),
re = /_500(\.(?:jpg|png|gif))$/
if (img === null || !img.src.match(re)
|| ((img.width && img.width < 500) && (img.height && img.height < 750))) return
img.src = (img.id && /^pano_/.test(img.id)) ?
img.src.replace(/\.jpg/, 'h$&') :
img.src.replace(re, '_1280$1')
img.style.width = img.style.height = 'auto'
img.style.maxWidth = img.style.maxHeight = 'none'
window.setTimeout(function() {
if (nextElem.offsetTop - postMedia.offsetTop <= 30)
img.src = img.src.replace(/_1280(\.(?:jpg|png|gif))$/, '_500$1')
}, 3000)
}
Array.prototype.slice.call(
document.querySelectorAll('li.post_container')
).forEach(highRes)
document.body.addEventListener('DOMNodeInserted',function(evt){
if ( /(?:^| )post_container(?:$| )/.test(evt.target.className) ) highRes(evt.target)
}, false)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment