Checking TelkomSpeedy Usage Using XMLHTTPRequest

If you have a TelkomSpeedy ADSL connection, oftenlly you'll check your internet account usage. The bad thing is, you need to access telkom's website download their huge flash just for view a couple lines of information about bandwith limit and usage. So, I've create a little javascript application for viewing current TelkomSpeedy usage. I mean, just the usage

This little script is utilizing the useful XMLHttpRequest and Javascript capabilities. The XMLHTTP object will do all the HTTP communication. This javascript can be run in your Windows Box using WScript.exe or CScript.exe, this two apps is shipped with your Windows instalation.

Usage

You can directly download the scripts here. Just edit the files with notepad to change the username and password with your speedy account username and password. And then, connect to internet with your speedy account, run the file by double-click it.

Here's the screenshot:

For developers, here a little bit explanation about the script. First we create the xmlhttp object

var xmlhttp = false;

// create xmlhttp object
try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
  try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch(e) {
    // no xml http, bail
    WScript.Echo("Error, cannot create XMLHTTP object");
    WScript.Quit();
  }
}

And then, we need to send the login information, and retrieve the session cookie

var cookie = '';
var logged_in = false;

xmlhttp.open("POST", "http://divre5.telkomspeedy.com/session.php", false);
xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState==4) {
    // retrieve session cookie
    cookie = xmlhttp.getResponseHeader('set-cookie');
    //check for login status
    body = xmlhttp.responseText;
    if (body.match(/location.href='\/\?'/)) {
      logged_in = true;
    } else {
      WScript.Echo("Error, login failed!");
      WScript.Quit();
    }
  }
}
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send('username='+username+'&password='+password);

When our loggin success, their website gives a JS redirection code:

location.href='/?';

So we just need to follow their redirection and parse the speedy bandwith info.

xmlhttp.open("POST", "http://divre5.telkomspeedy.com/?", false);
xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState==4) {
    cookie = xmlhttp.getResponseHeader('set-cookie');
    body = xmlhttp.responseText;
    // retrieve speedy usage
    pos = body.indexOf('Sisa Limit');
    limit = body.substring(pos + 33, pos + 38);
    pos = body.indexOf('Pemakaian');
    used = body.substring(pos + 32, pos + 37);
    WScript.Echo("Speedy Usage For: " + username + "\nSisa Limit: " + limit + "%\nTerpakai  : " + used + "%" );
  }
}
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Cookie", cookie);
xmlhttp.send('');

And there's we grep the useful information of speedy usage, minus downloading the image and javascript.

Attachment

13 Comments | [Put comments]

  1. gravatar Aryo Sanjaya - December 25, 2006

    Great script! Unfortunally, I have no Speedy connection :(
  2. gravatar Kiyat - January 1, 2007

    Finnaly, this trick is very usefull btw how about application for check speedy billing that is downloaded from telkomspeedy web? but i think this is better, small and useful mas aryo, biasane pake opo :p
  3. gravatar JOKERz - February 6, 2007

    Cool!! But speedy already had tool for that. http://www.telkomspeedy.com/new/download/InstallerSpeedyAlertNasional.zip
  4. gravatar ferdhie - February 8, 2007

    why download and use 2 megs application if all you need is only the percentage use info? "Don't use a cannon to kill a mosquito" hehehe
  5. gravatar JOKERz - February 10, 2007

    Size does matter Right?!?!?! Btw, can you add more detail about how much the bandwidth has been used. Not just the percentage.
  6. gravatar ferdhie - February 10, 2007

    # Btw, can you add more... I'll work on that, thanks for the input
  7. gravatar ndra - March 9, 2007

    kok gua coba masih error ya? syntak username & passwordnya yg bener gimana? bisa kasih contoh?
  8. gravatar ferdhie - March 9, 2007

    Biasa kok mas, username: #####@telkom.net dan password: bla2 btw, klo boleh tau, pesan errornya apa yak?
  9. gravatar ferdhie - March 10, 2007

    buat mas ndra: u/ linux ada toolnya mas: http://ferdianto.com/2007/03/10/checking-speedy-usage-in-python/
  10. gravatar benybee - December 20, 2007

    saya di daerah sini mas: https://divre1plg.telkomspeedy.com/ url yang perli saya ganti dah di ganti.. user:pass dah di masukin katanya error ngga bisa loggin... koq ngga bisa yah.. apa mang dah berubah lagi... tegkyu mas ferdhie
  11. gravatar Zoiz - January 11, 2008

    Lol, kewl script.. haha
  12. gravatar Joandi - July 2, 2008

    lu lagi bikin apa sih? ribet amat? bikinan gue ga pake password nih hahaha, jalan di semua sistem operasi! http://www.joandilee.com/2008/05/31/telkom-speedy-alert-community-edition/
  13. gravatar Joandi - July 2, 2008

    just type and click... lagian kenapa kalo ga pake password? emangnya lu tau no speedy tetangga lu? haha...

Leave a Reply