Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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

share|improve this answer

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/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.