2

I installed Fluid to make a Facebook app that was essentially the mobile version stacked on a corner (if you know Fluid, you know what I mean) and I feel like there is a feature missing. The ability to refresh the content of the page every X time.

Anyone know how to do that?

2 Answers 2

3

Fluid supports user scripts which are essentially javascript codes to modify the behavior of the website (also styles to modify its looks).

Once you've created you app, right click on the icon in the status bar, and access the user scripts. Create a new one that will target the appropriate url (in my case Facebook.com) and add the following code. Not getting into too much details, but basically it will count for 60 seconds after the last user interaction with the document, to prevent the page from reloading while we are doing something.

var refreshRate    = 600; //<-- In seconds, change to your needs
var lastUserAction = 0;

function resetCounter(){
    lastUserAction = 0;
}

setInterval(function(){
    lastUserAction++;
    if(lastUserAction >= refreshRate){
        window.location.reload();
        lastUserAction = 0;
    }
}, 1000);

document.onkeypress  = resetCounter;
document.onmousemove = resetCounter;

enter image description here

2

I created a updated version of what you are using because in cases on mac I would get the timer reset when I gave the window focused anyway here is my code on JSfuddle.

http://jsfiddle.net/newdark/rGRA3/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .