As I understand, it's not possible to inject an open tab with an iFrame if it's a system page. Using this for reference I have my extension opening as an iFrame. However I would like the extension to open as a popup (what seems to be default behaviour for most extension) if the tab is not injectable.
I would presume it's a function that I could call in the background.js
file, instead of sending a message to the content-script.js
but looking for the Docs I can't find anything relevant.
chrome.browserAction.onClicked.addListener(function(){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id,"toggle");
})});
SimilarWeb do a nice example of this. -Clicking on SimilarWeb when there is just a blank tab:
-Clicking on SimilarWeb with a website loaded in a tab:
This sort of works, but only once each time the browser is opened background.js
-
chrome.browserAction.onClicked.addListener(function () {
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
if (tabs[0].url.includes("chrome://")) {
chrome.browserAction.setPopup({popup: "index.html"});
} else {
chrome.tabs.sendMessage(tabs[0].id, "toggle");
}
})
});