Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Thanked 0 Times in 0 Posts

    Watching a countdown timer with greasemonkey?

    Hello all,

    I'm new here and first of all I'd like to admit that I know almost nothing about javascript, I'm just starting out and I don't know the lingo. I'm kinda just doing this for fun.

    What I would like to do is watch a countdown timer on a page, like the ones on swoopo.co.uk and then perfom an action depending on what time is left on the timer.

    I've installed DOM inspector on Firefox and poked around with javascript shell and I think I've figured out how to read the timer and assign that to a variable, something like this -

    var timer=document.getElementById('counter_index_page_162980').innerHTML;

    Now I need to watch that so I guessed this would do -

    while (timer!=="00:00:01")
    var timer=document.getElementById('counter_index_page_162980').innerHTML;

    alert('timer at 1 sec!');

    But that just brings up an "unresponsive script" error in my browser.

    Am I even close to the mark? I know I'm not going to win any auctions with this but I've already paid for the bids so I may as well use them now.


  • #2
    Regular Coder
    Join Date
    Mar 2009
    Portland Oregon
    Thanked 63 Times in 62 Posts
    font: bold 12px MS Sans Serif ;
    <script type = "text/javascript">
    var txt ="";
    var num = 5;  /* erase after num seconds, adjust to suit*/
    var loopspeed=.01;
    function showLoad() {
    num -=loopspeed;
    txt = "This countdown will end in " + num.toFixed(2) + " seconds. <br><br>This page best viewed with Firefox<img src='http://i41.tinypic.com/4ictfp.jpg' style='position:absolute;top:250;left:500;'>";
    document.getElementById("a").innerHTML = txt;
    if (num < loopspeed) {  		
    txt = "Loading completed.<br><br>Thank you for using <big><big>TinyScript<big><big>";
    document.getElementById("a").innerHTML = txt;
    setTimeout("doneload()", 2500)
    setTimeout("showLoad()", 10)
    function doneload(){
    <body onload = "showLoad()">
    <div id = "a" class="pageload"></div>
    here is a count down script. Someone here posted it but I added a few things
    Last edited by TinyScript; 03-21-2009 at 02:41 AM.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts