iStat Pro Widget External IP Fix

March 17th, 2013 by Ken Chang

Not sure how long it’s been but I just noticed the other day that my widget was no longer showing my external IP. Instead it’s just stuck “Updating…” Looks like the good people at iSlayer have phased out the script that was used so those of us hanging on to iStat Pro are left out again.

But once again, just like the last fix, this one’s a quick and easy edit too!

The file you’ll need to edit this time is ~/Library/Widgets/iStat\ Pro.wdgt/scripts/core.js

Find this function:
function getExtIP(){

And replace this line:
ipURL = 'http://whatsmyip.islayer.com/?random='+new Date().getTime();

With this line:
ipURL = 'http://www.whatsmyip.us/showipsimple.php?random='+new Date().getTime();

Then, just above this “if” statement:
if(extIP.length < 20 && ipConnection.status == 200 && extIP.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)){

Add these 2 lines:
extIP_len = extIP.length;
extIP = extIP.substring(16, (extIP_len - 3));

So that you have:
extIP = ipConnection.responseText;
extIP_len = extIP.length;
extIP = extIP.substring(16, (extIP_len - 3));
if(extIP.length < 20 && ipConnection.status == 200 && extIP.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)){

Now just save the file and restart the iStat widget by either re-adding it, or just click on the widget and hit Command-R.

Posted in How To, Mac | 4 Comments »

4 Responses

  1. Daniel Says:

    Thanks!

  2. jumbo Says:

    Thank you very much. Worked perfectly on OS X Mavericks.

  3. Alexander Says:

    Cool! On 10.9 working perfect.
    Love istat pro

  4. muzso Says:

    Instead of adding these two lines:
    extIP_len = extIP.length;
    extIP = extIP.substring(16, (extIP_len – 3));

    I took a more generic approach by replacing this line:
    if(extIP.length < 20 && ipConnection.status == 200 && extIP.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)){

    With these three:
    ip_regex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
    if(extIP.length < 100000 && ipConnection.status == 200 && extIP.match(new RegExp(ip_regex))){
    extIP = extIP.replace(new RegExp("^(.*[^\\d])?(" + ip_regex + ")([^\\d].*)?$"), "$2");

    This way you can use a lot wider range of "what's my IP" services and the script will take the first IP looking string from the result.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.