cfg
7/27/2011 - 7:22 PM

Scroll to the first new tweet on twitter.com

Scroll to the first new tweet on twitter.com

/*
See: http://coreygilmore.com/blog/2011/07/20/bookmarklet-scroll-to-the-first-new-tweet/
*/
javascript:(function(){
  if( document.getElementsByClassName ) {
    var t=document.getElementsByClassName("last-new-tweet")[0];
    if(t) {
      window.scrollTo(0, t.offsetTop + t.offsetParent.offsetTop );
    }
  } else {
    var els = document.getElementsByTagName("div"), elsLen = els.length, pattern = new RegExp("(^|\\s)last-new-tweet(\\s|$)");
    for (var i = 0; i < elsLen; i++) {
      if ( pattern.test(els[i].className) ) {
       window.scrollTo(0, els[i].offsetTop + els[i].offsetParent.offsetTop );
       break;
      }
    }
  }
})();
/* Minified:

javascript:(function(){if(document.getElementsByClassName){var t=document.getElementsByClassName("last-new-tweet")[0];if(t){window.scrollTo(0,t.offsetTop+t.offsetParent.offsetTop);}}else{var els=document.getElementsByTagName("div"),elsLen=els.length,pattern=new RegExp("(^|\\s)last-new-tweet(\\s|$)");for(var i=0;i<elsLen;i++){if(pattern.test(els[i].className)){window.scrollTo(0,els[i].offsetTop+els[i].offsetParent.offsetTop);break;}}}})();

*/