FFixer

By Vaughan Chandler Last update Mar 9, 2011 — Installed 14,796,132 times.

auto-updating home stream

in
Subscribe to auto-updating home stream 10 posts, 3 voices



thezachperson31 Scriptwright
ChromeWindows

Could you please add the feature from this script http://userscripts.org/scripts/show/11992 that makes the homepage automatically load new posts?

 
Vaughan Chan... Script's Author
FirefoxX11

Hi, I was actually working on this sort of functionality a couple days ago... The next release will be able to do it.

 
thezachperson31 Scriptwright
FirefoxWindows

Oh, okay. Looking forward to the next version! :)

 
sizzlemctwizzle Scriptwright
FirefoxMacintosh

That feature has been broke in my script for some time now (Facebook changed something). If you do figure out how to fix it mind sending me a message? Likewise, I'll do the same.

 
Vaughan Chan... Script's Author
FirefoxX11

@sizzlemctwizzle - I don't have the development version of my script on me now, but what I was trying out was to use one of the mutation events (I think it was either DOMAttrModified or DOMSubtreeModified) to detect when the "new posts" link is visible and then click it. Facebook made it complicated by always having the link present but hiding it when there are no new posts, so you can't just detect the presence of the link.

The last time I checked (maybe 2 weeks ago) it was working, but the event was firing much more often than I expected, so I might need to optimize it a bit.

I'll give you something more concrete next time I look at the code.

 
sizzlemctwizzle Scriptwright
SafariMacintosh

That sounds much more efficient then what I was doing. I was using an interval to check if the link was visible. It stopped working for whatever reason and I've been to busy worrying about other things to try fixing it.

 
thezachperson31 Scriptwright
FirefoxWindows

Well, Facebook doesn't check for new posts very often anyway. The easiest way would probably be to get the Javascript function from the link, remove the element (important to avoid it momentarily popping up when loading new posts), and then load that function every 30 seconds or so using setInterval. Even if there aren't any new posts it wouldn't cause a problem or show a notice. No need for DOM event listeners or complex code.

 
thezachperson31 Scriptwright
FirefoxWindows

Here's what I have. It updates the feed every 30 seconds by running the "show new posts" function, since the built-in notifier only checks every 10 to 15 minutes. I removed the element containing the "new post" notification, as well as making the first feed item look the same as the rest for a temporary styling fix. Unfortunately, it only works if you go straight to the homepage and start from there. Also, there's a bug where after 15 to 20 minutes of running the script it would load old items and stick them at the top for some reason.

// ==UserScript==
// @name Facebook Live News Feed
// @description Automatically loads new News Feed items. Must have navigated directly to the home page for this to work.
// @include http://www.facebook.com/home.php
// @include http://www.facebook.com/home.php?*
// ==/UserScript==

// Set number of seconds between refreshes
var FLNF_Delay = 30;

var FLNF_NewPostNotification_ElementParentDOM = document.getElementById("home_stream").childNodes[2];
var FLNF_NewPostNotification_ElementContainerDOM = FLNF_NewPostNotification_ElementParentDOM.childNodes[0];
var FLNF_NewPostNotification_ElementDOM = FLNF_NewPostNotification_ElementParentDOM.childNodes[0].childNodes[0];
var FLNF_NewPostNotification_LoadNewJS = FLNF_NewPostNotification_ElementDOM.getAttribute("onclick");

FLNF_NewPostNotification_ElementParentDOM.removeChild(FLNF_NewPostNotification_ElementContainerDOM);

var FLNF_Updater = document.createElement('script');
FLNF_Updater.setAttribute("type","text/javascript");
FLNF_Updater.innerHTML = "setInterval('" + FLNF_NewPostNotification_LoadNewJS + "', " + FLNF_Delay*1000 + ");";
document.getElementsByTagName("head")[0].appendChild(FLNF_Updater);

var FLNF_NoFirstPost = document.createElement('style');
FLNF_NoFirstPost.setAttribute("type","text/css");
FLNF_NoFirstPost.innerHTML = ".UIStory_First{ border-top: 1px solid #eee !important; padding-top: 7px !important; }";
document.getElementsByTagName("head")[0].appendChild(FLNF_NoFirstPost);

There's probably a better solution, but this works.

TODO: remove empty divs when there are no new items

 
Vaughan Chan... Script's Author
FirefoxX11

Thats a good idea, I'll check this approach too.
And since Facebook Fixer already has to figure out what page you're on it wouldn't matter whether you went directly to the home page or if you got there via another page.
Hmmm... If facebook usually checks every 15 or so minutes for updates, and your code has a bug every 15 or so minutes, I guess those are related. Maybe they're using some kind of timestamp.

 
Vaughan Chan... Script's Author
FirefoxX11

Tonight's release includes the ability to auto-refresh the news feed every minute. In the next version I'll probably add an option to control how often it refreshes.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel