External api calls from within chrome extensions..

2,179 views
Skip to first unread message

saurabh datta

unread,
Aug 6, 2015, 1:42:18 PM8/6/15
to Chromium-extensions
Hello everyone.. 
I'm new in web programming .. I'm doing an art project and making a chrome app.. 
Few first steps in experimentation are:
>Log your own IP address  and your country..
>Log the visiting website's IP and country ..
> Do something after that.. 

I found a chrome extension which throws IP of visiting sites. ([1] https://github.com/tinybigideas/WebsiteIP)
I console logged it for simplicity and removed unnecessary stuff and then loaded it.. It works.. 

Then I found another jquery based api to know the country code of a specific ip address or even my own ip address ( https://ipinfo.io/developers ) .. It makes a http/https call.  
When I put that jquery snippet into the ip.js file[1] combined with the other code, it did nothing.. I even got an ssl request calls on that API for security but it seems external calls to other api is not possible.. 

I'm a newbie and doesn't have much insight here.. please help me to solve this problem .. 


Mohammad Arafath

unread,
Aug 8, 2015, 5:01:32 AM8/8/15
to saurabh datta, Chromium-extensions
does your manifest allow this domain ?

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/cbb2954b-fb00-4146-9475-6eaa5672ad3c%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.



--
Mohammad Arafath | SDE | Boomerang Commerce Inc | +91-9966245529
We guarantee revenue and profit lift. learn more about Price Perception.

Timo Reimann

unread,
Aug 9, 2015, 3:59:24 AM8/9/15
to Chromium-extensions
You should read Chrome's documentation on debugging extensions and try to figure out what part of your code isn't working (and for what reason): https://developer.chrome.com/extensions/tut_debugging

saurabh datta

unread,
Aug 9, 2015, 4:55:43 AM8/9/15
to Chromium-extensions, dattasa...@gmail.com

On Saturday, 8 August 2015 17:01:32 UTC+8, Mohammad Arafath wrote:
does your manifest allow this domain ?
On Thu, Aug 6, 2015 at 11:12 PM, saurabh datta <dattasa...@gmail.com> wrote:
Hello everyone.. 
I'm new in web programming .. I'm doing an art project and making a chrome app.. 
Few first steps in experimentation are:
>Log your own IP address  and your country..
>Log the visiting website's IP and country ..
> Do something after that.. 

I found a chrome extension which throws IP of visiting sites. ([1] https://github.com/tinybigideas/WebsiteIP)
I console logged it for simplicity and removed unnecessary stuff and then loaded it.. It works.. 

Then I found another jquery based api to know the country code of a specific ip address or even my own ip address ( https://ipinfo.io/developers ) .. It makes a http/https call.  
When I put that jquery snippet into the ip.js file[1] combined with the other code, it did nothing.. I even got an ssl request calls on that API for security but it seems external calls to other api is not possible.. 

I'm a newbie and doesn't have much insight here.. please help me to solve this problem .. 


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

saurabh datta

unread,
Aug 9, 2015, 6:48:05 AM8/9/15
to Chromium-extensions
It seems background.js is not even firing the get call and then even if it does how do I send the response to content.js for console logging? 

Timo Reimann

unread,
Aug 9, 2015, 9:51:23 AM8/9/15
to Chromium-extensions
As mentioned before, you should really learn how to debug Chrome extensions. The console output immediately showed the following problems when I tried to use your extension:


To solve the first problem, you need to relax the default CSP settings as described on SO here. More on CSP in Chrome can be found here.


To solve the second problem, you need to fix your (erroneous) usage of the tabs API to send messages: Specify the receiving tab's ID as the first parameter and the entire object of data you want to push as the second parameter. The official tabs API documentation and the section describing simple message passing are your friends. (By the way, you already have a "more correct" approach in your code commented out.)


In general, I would advise to try to achieve a better understanding of Chrome extension development to solve these and similar problems, referring to the official documentation again.


HTH,


Timo

saurabh datta

unread,
Aug 9, 2015, 12:45:19 PM8/9/15
to Timo Reimann, Chromium-extensions
Thanks Timo.. 
I'd take a look.. 

Saurabh Datta
(‾⌣‾)♉
Copenhagen Institute of Interaction Design
IDP 2014
//////////////////////////////////////////////////////////////////////////
mobile(DK):------------ +45 50109035
Primary email:--------dattasa...@gmail.com
Email:----------------------s.d...@edu.ciid.dk
Portfolio:-----------------dattasaurabh.com
//////////////////////////////////////////////////////////////////////////






--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.

To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
Reply all
Reply to author
Forward
0 new messages