I send message using chrome.runtime.sendMessage({});
from my content.js
and it is received by background script which opens a HTML file:
background.js
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
chrome.tabs.create({url: 'popup.html'});
});
If the popup.html
is already open, I don't want to open it again, so there should be a if
condition to check whether it is already open.
But what do I put in side the if
condition before chrome.tabs.create({url: 'popup.html'});
in the background script?
Please note that I am looking the solution inside banckground script.
Please provide the solution according to the scripts given in this answer.
from Check whether an URL is already open or not in Background script
No comments:
Post a Comment