Sunday, May 8, 2011

Sorting Facebook feeds in chronological order

College students spend lots of time on Facebook and virtually use it to share and organize their shcedules and course materials. Obviously, things get out of control and you end up with a very long and entangled feed that you might find yourself in a real need to explore or even worse, scan for something important.

So, one day a student of mine posted (!), wondering if there were any group settings that would arrange posts in reverse chronological order, presumably to save some time. That post caught my attention and eventually, I decided to prepare a bookmarklet for this exact purpose. It was pretty much straightforward but unfortunately, it would only work for groups. Someone may find it worthwhile to adapt it to the home/profile feeds, though.

Update: It seems the student got interested in this sort of JS magic and she actually took it a step further to work for the home feed as well.
// This snippet is licensed under a Creative Commons Attribution 3.0 License.
// Authors: Ahmed Abdelkader and Nancy Iskander
javascript:{
    var flist = document.getElementById('home_stream');
    if (flist == null)
    flist = document.getElementById('pagelet_group_mall').children[0].children[0];
    var far = new Array();
    var dates = {};
    while (flist.children.length) {
        var abbrs = flist.children[0].getElementsByTagName('abbr');
        if (abbrs.length) {
            dates[flist.children[0].id] = abbrs[0].getAttribute('data-utime');
            far.push(flist.children[0]);
        }
        flist.removeChild(flist.children[0]);
    }
    far.sort(function(a, b){return dates[b.id] - dates[a.id];});
    for (var i = 0; far.length - i; ++i)
        flist.appendChild(far[i]);
    void(0);
}
To create the bookmarklet, we just need to compress that and put it in a hyperlink. Just drag this link: Feed-Repairo!, into your browser's Bookmarks Toolbar to add the bookmark and you can easily rename it if you please. That's it! Whenever you need to sort out your group feeds, all you need to do is click the bookmark. Let me know if it works for you or you encoutner any bugs. Enjoy!

Update 8/23/2013: Drag this link if you want to sort ascendingly Repairo-Feed!
Update 3/23/2014: flist is not at the root container anymore; so we added another .children[0] and all is fine. (Many thanks to Jeff E)

21 comments:

Unknown said...

It works well msAllah ..

Nancy Iskander said...

[Student in question!]
I tried it with the homepage (only required 2 minor changes): http://pastebin.com/vCg6gwwX (I pasted it here first, but it looks better like that ^_^). Thanks again!

Unknown said...

Works All fine...
Thanks very much!

Usama Elnily said...

I like ...

Anonymous said...

It works with me.I'm really like it.

Anonymous said...

impressive!

Anonymous said...

this code doesn't work with me today
So What happen??

Ahmed Abdelkader said...

Apparently, they changed some interface elements. I updated the script, let me know if it still doesn't work for you ;)

Anonymous said...

Thank you! This is fantastic. My Facebook groups will never be the same. I'll share your good work with others so they can benefit, too. :)

lizardj68 said...

Can you tweak it so it will sort dates in ascending order instead of descending order? It would really help me to clear some old posts from the group that I admin... Thanks!
Liz

Ahmed Abdelkader said...

@lizardj68: Check the updated post. Just note that this trick sorts the posts you already loaded on your screen. You still have to scroll down to load more and more posts before you can get to the old posts. Maybe there's something we can do about all that scrolling ..

Jeff E said...

It broke again...
flist is not at the root container anymore; add another .children[0] and all is fine. Thanks for making this!

RadioRao said...

Could someone please explain this in Sesame Street terms? ;) I would love to clean up my group.

Ahmed Abdelkader said...

@RadioRao: thanks for stopping by!

If you are browsing the posts in your group, say you can see ~50 posts, this script helps you sort these posts by the time they were posted (rather than by the most recent comment).

This script doesn't help you load any posts, for example, things that happened long ago. However, if you keep scrolling to load more posts manually, the script will still help by sorting them.

Hope this helps :)

Anonymous said...

Works perfectly, thanks!

Anonymous said...

Honestly, thank you for sharing this!

Anonymous said...

Thank you, this will make my life easier :)

Anonymous said...

Thank you so much! :)

Unknown said...

WOW!!! I neeeeeededdd this soo much!!!!
Thank you, thank you!!!!!!

Andreea said...

Hei!I find your post very useful, but i don`t know exactly were to click to enter the page. Can you give me a link? Thank you very much!

Ahmed Abdelkader said...

@Andreea: Glad you find it very useful!
Think of the bookmarklet as a clickable button that executes a particular function. The button will always be there, but the function it should execute only makes sense if you are browsing feeds on Facebook.

To create the button, drag the link into your Bookmarks Toolbar. The browser will create a clickable button for you in the toolbar.
To use the button to sort the Facebook feed -while you are actually browsing/scrolling through the feed- just click the button.
Otherwise, the button should be harmless, even if you click it while browsing a different website.

This video segment illustrates the process: http://www.tubechop.com/watch/6095749

If you are not familiar with bookmarks and the Bookmarks Toolbar, you'd need to learn about it first before you can do things the way I described. The following link may help with this: http://www.howtogeek.com/189358/beginner-geek-how-to-use-bookmarklets-on-any-device/.