Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to determine a tab's opener within a Google Chrome extension?

I am looking for a way to determine a given tab's opener (parent tab) within a Google Chrome extension.

I've looked at the documention for Tab but there doesn't really seem to be anything that would yield this information. http://code.google.com/chrome/extensions/tabs.html

I've tried injecting this content script into pages (thinking I could pass the value to my background page):

alert(window.opener);

.. but it just yields null.

The best thing I've come up with so far is to keep track of the currently focused tab, and whenever a new tab is created, just assume that the focused tab is the opener/parent of the new tab. I believe this would de facto identify the parent tab correctly most of the time since background tabs rarely (are allowed to) open new pages. However, it seems kludgey and potentially inaccurate at times -- for example, if another extension opened a new tab, this method may misidentify the new tab's opener.

like image 578
joelpt Avatar asked Jun 26 '10 16:06

joelpt


People also ask

Can you check how many tabs are open in Chrome?

Then when you hover (if you have Bluetooth mouse enabled) or tap the tab icon (with your finger) (the :D), it will tell you how many tabs you have open. Like on mine, it said 713 tabs open.

Can Chrome extensions be detected?

“Chrome extensions can be detected by fetching their web-accessible resources — the files inside an extension that web pages can access,” z0ccc explained. “The detected extensions can be used to track you through browser fingerprinting.”

Does Chrome have a tab manager?

Tab managers — also known as tab organizers or session managers — are only available as extensions or plugins for your Chrome browser. That's because Chrome doesn't have built-in tab organization, aside from tab groups (which you can read about here).


1 Answers

Update: it is now possible to reliably determine a tab's opener tab within a Chrome extension natively using the newly added webNavigation API, and specifically by hooking the onCreatedNavigationTarget event.

https://code.google.com/chrome/extensions/trunk/webNavigation.html

like image 94
joelpt Avatar answered Oct 15 '22 13:10

joelpt