this site best experienced with a standards compliant browser.

robzand.com

friendfeed “back to top” link

Thursday, July 3rd, 2008 at 11:43 am

i have a real simple enhancement for friendfeed. a “back to top” link after every entry.

i created this because i never really leave page 1, which i’ve lengthened with internet duct tape to show 50 posts. i found i was doing a great deal of scrolling to get back to the top of the page once i had read it, so i created this rudimentary script. it’s far from perfect, though, embarrassing in fact, and i’m hoping somebody can fix the kluge i’ve created to detect page refresh. i’ve given up on finding the refresh event… i also added a light horizontal line and some space between posts for legibility.

here’s a screenshot:

friendfeed back to top link

and here’s the script (requires greasemonkey):

// ==UserScript==
// @name friendfeed back to top navigation
// @namespace http://robzand.com
// @include http://friendfeed.com/*
// @exclude http://friendfeed.com/settings/*
// @version 1.1
// ==/UserScript==
function insertLinks(){
var topLink = 'top';
var c0 = 'rsz200';
if(document.getElementById(c0) == null){
l = document.createElement('a');
l.name = topLink;
var el = document.getElementById('tabhead');
el.parentNode.insertBefore(l,el);
var ar = document.getElementById('feed').getElementsByTagName('div');
for(i=0;i if(ar[i].className.indexOf('cluster')!=-1){
a = document.createElement('a');
a.appendChild(document.createTextNode('back to top'));
var dl = document.location.href.replace(document.location.hash,'');
a.href=dl + '#' + topLink;
a.style.lineHeight='3em';
a.style.color='#ccc';
if(i==0){a.id=c0}
ar[i].style.borderBottom = '1px dotted #ccc';
ar[i].style.paddingBottom = 'bottom:1.75em';
ar[i].appendChild(a);
}
}
}
}
insertLinks();
setInterval(insertLinks,5000)

would love to see a better answer. thanks.

filed under: other
comments: Comments

blog comments powered by Disqus