Adding ipify API support in Chrome Extension - What Is My IP

in utopian-io •  7 years ago 

Previously, the Chrome Extension Show My IP has been both accepted by utopian.io and Chrome Webstore. Today I have spent some time adding support for using ipify API to get the IP Address. Therefore, the chrome extension supports 5 API servers which makes it more robust.

Chrome Webstore: https://chrome.google.com/webstore/detail/show-my-ip-addresses-exte/opljiobgnagdjikipnagigiacllolpaj
Github: https://github.com/DoctorLai/what-is-my-ip
This commit: https://github.com/DoctorLai/what-is-my-ip/commit/13a5fc8b9074651d36573bae061ae6ed6896134e#diff-77a711c4c2c9fd1e7125ed653dc9e3ab

The code:

function callThirdParty(server, name) {
    var api = server;
    logit("Connecting " + server + " ...");
    $.ajax({
        type: "GET",
        url: api,
        success: function(data) {
            if (data && data['ip']) {
                current_ip = data['ip'];
                $('pre#ip').append(current_ip + "\n");
            }
        },
        error: function(request, status, error) {
            logit('Response: ' + request.responseText);
            logit('Error: ' + error );
            logit('Status: ' + status);
        },
        complete: function(data) {
            logit('API Finished: ' + name + " Server!");
        }             
    });    
}
document.addEventListener('DOMContentLoaded', function() {
    getLocalIPs(function(ips) { // (html comment removed:  ips is an array of local IP addresses.
        ipaddress = ips.join('\n');
        $('pre#ip2').html(ipaddress);
        var manifest = chrome.runtime.getManifest();
        logit(manifest.name);
        logit("Version: " + manifest.version);        
        logit("Chrome Version: " + getChromeVersion());
        logit("May you do good, not evil.");
        callServer("helloacm", "East USA");
        callServer("uploadbeta", "UK");
        callServer("happyukgo", "Tokyo Japan");  
        callServer("steakovercooked", "West USA");  
        callThirdParty("https://api.ipify.org?format=json", "ipify.org");
    });
}, false);

It has been also integrated in this online tool to get the IP.

It works!

image.png

Proof of Work

doctorlai is my github ID and you can see my steemit URL listed on my profile page:
Feel free to submit your Pull Requests at: https://github.com/DoctorLai/what-is-my-ip



Posted on Utopian.io - Rewarding Open Source Contributors
)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  ·  7 years ago (edited)

Thank you for the contribution. It has been approved.

You could blend the raw links with the text so that the post would look nicer. You also left a parenthesis at the bottom of the post.

You can contact us on Discord.
[utopian-moderator]

  ·  7 years ago 

Thanks. I have no idea about the parenthesis.... maybe a bug.

Hey @justyy I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x