Applescript to reload a Safari page

Discussion in 'Mac Apps and Mac App Store' started by mrsir2009, Feb 2, 2013.

  1. mrsir2009
    Expand Collapse
    macrumors 604

    mrsir2009

    Joined:
    Sep 17, 2009
    Location:
    Melbourne, Australia
    #1
    Would anyone happen to know what the applescript script would be to reload a page on Safari at intervals - Say, reload it every 10 minutes, for example?

    Thanks! :)
     
  2. justperry, Feb 2, 2013
    Last edited: Feb 2, 2013

    justperry
    Expand Collapse
    macrumors 603

    justperry

    #2
    Does the next thing work for you?

    Save this as a bookmark, name it reload or so, the if you want to reload a page click this bookmark(in Bookmark Bar) and it will ask you the time to reload.

    javascript:(function(p){open('','',p).document.write('%3Cbody%20id=1%3E%3Cnobr%20id=2%3E%3C/nobr%3E%3Chr%3E%3Cnobr%20id=3%3E%3C/nobr%3E%3Chr%3E%3Ca%20href=%22#%22onclick=%22return!(c=t)%22%3EForce%3C/a%3E%3Cscript%3Efunction%20i(n){return%20d.getElementById(n)}function%20z(){c+=0.2;if(c%3E=t){c=0;e.location=u;r++}x()}function%20x(){s=t-Math.floor(c);m=Math.floor(s/60);s-=m*60;i(1).style.backgroundColor=(r==0||c/t%3E2/3?%22fcc%22:c/t%3C1/3?%22cfc%22:%22ffc%22);i(2).innerHTML=%22Reloads:%20%22+r;i(3).innerHTML=%22Time:%20%22+m+%22:%22+(s%3C10?%220%22+s:s)}c=r=0;d=document;e=opener.top;u=prompt(%22URL%22,e.location.href);t=u?prompt(%22Seconds%22,60):0;setInterval(%22z()%22,200);if(!t){window.close()}%3C/script%3E%3C/body%3E')})('status=0,scrollbars=0,width=100,height=115,left=1,top=1')
     
  3. mrsir2009
    Expand Collapse
    thread starter macrumors 604

    mrsir2009

    Joined:
    Sep 17, 2009
    Location:
    Melbourne, Australia
    #3
    Man, that's fantastic :D Thanks a ton!
     
  4. justperry
    Expand Collapse
    macrumors 603

    justperry

    #4
    This code seems to mess with MR's page formatting (this thread).:eek:

    The only problem with this is you get another tab and it needs to be open afaik, I just tested to drag the Tab off so it opens in another window but then it does not work anymore, probably lost connection with the other tab, might be sandboxed.

    Cheers Perry
     
  5. mrsir2009
    Expand Collapse
    thread starter macrumors 604

    mrsir2009

    Joined:
    Sep 17, 2009
    Location:
    Melbourne, Australia
    #5
    Funny... Because it works fine with me without opening any other tabs.
     
  6. justperry
    Expand Collapse
    macrumors 603

    justperry

    #6
    I am on 10.5.8 with safari 5.0.6, that might be the difference.
     
  7. mrsir2009
    Expand Collapse
    thread starter macrumors 604

    mrsir2009

    Joined:
    Sep 17, 2009
    Location:
    Melbourne, Australia
    #7
    Haha, probably... I’m on ML with the latest version of Safari. Thanks again for the script, btw!
     

Share This Page