0

UPDATE: Found How can I get the current tab URL for chrome extension?

I require the tab.ID to refer to a tab of a specific URL. However not sure if this means me issuing the extension refresh itself constantly (or will the iframe the extension is contained within do this live)?

================

OP

I would like to develop a Chrome extension. At this stage of development what I need it to do is 'know' which website it is on. I'm not very experienced with JavaScript (I have some experience developing applications in Java and C, whereas Python is kind of my specialty language and I've deployed a lot of powerful tools using this).

I'm not sure how to go about getting live information of the website the user is currently viewing without constantly refreshing the iframe the application is contained in. I'm thinking of some kind of for loop to do this work for me but I'm also worried about the rate at which this refresh is going to take place (I don't want Chrome to start CPU hogging if many tabs are open).

The framework I'm looking to use during development looks like this (not sure if this is ideal but this is what I have in mind)...

FOR [EXTENSION IFRAME]

{

Extension page IS Extension_OFFLINE (indicating tab is not on, online_example_page)

Extension page IS Extension_ONLINE (indicating tab is on, online_example page).

}

Such that [EXTENSION IFRAME] actively detects what web-pages you are viewing. I would like to avoid refreshing the extension constantly to get this information if possible.

So what it'll look like is the logo and html page will change depending on whether or not you're connected to the online_example page which could be https://example.com.

If the user is on different tabs this is fine. I only need it to detect at least one instance of https://example.com (so ideally ranging over all tabs).

Thank you in advance if you're able to help!

Community
  • 1
  • 1
  • http://stackoverflow.com/a/17826527/1586880 – dsgriffin Jan 25 '16 at 17:02
  • Try posting some actual code showing what yo have tried – ste-fu Jan 25 '16 at 17:02
  • This is what I mean, I'm not even sure exactly where to begin or how to interface the extension with the websites the user is on without constantly refreshing the extension for something like https://example.com. From your answer @daniel I'll try this to see what results I get. Can I ask if my assumption is correct: from this method that I'll have to refresh the extension for it to detect changes in the tab-ID? In addition I take it for... var activeTabId = arrayOfTabs[0].od – mmacheerpuppy Jan 25 '16 at 17:28
  • Correction; In addition I take it for... "var activeTabId = arrayOfTabs[0].id", [0] in the array always refers to the active tab (not the first tab for some reason)? – mmacheerpuppy Jan 25 '16 at 17:34
  • read these first, then you might have an idea of what you want to do: https://developer.chrome.com/extensions/samples , https://developer.chrome.com/extensions/getstarted – Marc Guiselin Jan 25 '16 at 18:14

0 Answers0