How to tell if a page is loaded as a popup or in a separate tab in chrome extension -
my chrome extension has page seen in popup or separate tab. when seen separate tab, need show small button @ corner of page. couldn't find way detect when page loaded in own tab.
use chrome.extension.getviews, returns array of window objects.
var tabs = chrome.extension.getviews({ type: "tab"}) if(tabs[0]) { console.log("inside tab") } var popups = chrome.extension.getviews({ type: "popup"}) if(popups[0]) { console.log("inside popup") } or chrome.tabs.getcurrent, returns tab object in callback.
chrome.tabs.getcurrent(function(tab) { if(tab) { console.log("inside tab") } else { console.log("inside popup") } })
Comments
Post a Comment