12 August, 2013

UserJS for Flickr: center the full size picture and kill the topbar


  This script centers the full size picture vertically (if the photo is bigger than the screen) and kills the topbar that obscures the view. It's triggered with a click on the page (except links).


▐▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▌

// ==UserScript==
// @name flickr
// @include *.flickr.com/*
// ==/UserScript==

window.addEventListener('DOMContentLoaded',function(){
if (/\/sizes\//gi.test(window.location.pathname))
  {document.onclick=function(event){
var tag = event.target.tagName.toLowerCase();
if (tag === 'a') {return;}


var x=document.getElementById('allsizes-photo');
window.scroll( findPos(x)[0] + parseInt((window.innerWidth/2)-(x.scrollWidth/2)), findPos(x)[1] + parseInt((x.scrollHeight/2)-(window.innerHeight)/2));

Flickr_nav_kill();
  }

}

else if (/\/[a-zA-Z0-9@]+\/[0-9]+\/(in\/)?/gi.test(window.location.pathname) && !/\/sizes\//gi.test(window.location.pathname))
{document.getElementById("photo-container").addEventListener('click',function(){
var loc = window.location.toString(); loc=loc.slice(0,(loc.indexOf('/in')));
window.location=loc +'/sizes/l/in/photostream/'} ,false)
  }
} ,false)



function findPos(elem) {var x =0, y = 0;
if (elem.offsetParent) {
do {x += elem.offsetLeft; y += elem.offsetTop;} while (elem = elem.offsetParent);
return [x,y];
}}


Flickr_nav_kill=function(){
var styles='#global-nav{position: absolute !important;top:0px !important;}#eyebrow{display:none !important}';
if(document.createStyleSheet){document.createStyleSheet('javascript:'+styles);}
else{newSS=document.createElement('link');newSS.rel='stylesheet';
newSS.href='data:text/css,'+escape(styles);
document.getElementsByTagName('head')[0].appendChild(newSS)};

}


▐▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▌



No comments:

Post a Comment