How to determine if the page is in browser action or sidebar

Have an addon that used to open an HTML file in a browserAction. I’m currently working on giving the option to open the same HTML file in a sidebarAction. However, I need to make a very minor modification to the page based on whether it’s in the browserAction vs the sidebarAction.

Is there a way to detect whether a given page is being opened in a browserAction window or a sidebarAction window using Javascript? Preferably, I’d like the page to be able to detect that on it’s own, but I can do messaging between the page and the background script, if necessary.

I know that obviously I could just include two HTML files (one for each) and make minor modifications to the HTML file to include a separate Javascript file for each version. However, that introduces more duplication and potentially makes it harder to maintain in the future.

The simplest option is to specify the file name with a get parameter. So popup.html?view=browserAction and popup.html?view=sidebarAction etc.


Hadn’t even thought about doing that!