Keeping chrome extension popup open when opening link in background tab - google-chrome

I searched all over and haven't found an answer. I'm developing a Chrome extension and would like to know how to make the popup window stay open if the user chooses to open a link in a new background tab. (For example, clicking on the link while pressing the "ctrl" key.) Currently when I do that, the popup closes even though the user stays on the current tab.
It is different than How to keep Google Chrome Extension popup open?, as that's talking about when the user focuses on a different window, then the popup closes. I'm talking about when the user specifically stays focused on the popup, as in the example given that the user presses "ctrl" while clicking on the link, that the focus stays on current page.

chrome.tabs.create({ url, active: false });
From the docs:
active (boolean, optional): Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see windows.update). Defaults to true.
Ref: https://developer.chrome.com/docs/extensions/reference/tabs/

Related

How to keep the Chrome extension window open after I click a link?

I'm having this issue with a simple extension I'm working on.
The extension consists of a bunch of links. When I click a single link, the extension closes.
I would like to keep the extension window open so I can open more links before closing the extension/clicking on the page to continue working.
Is there a way I can keep the extension open once a single link is clicked and only close it when I click on the page/lose focus?
Thanks.
Switching to another tab in the same window closes the popup because the popup is conceptually bound to the tab where it was invoked. When you open a URL it opens in a new active tab by default ("active" means it's currently in foreground), the old tab loses its active status, its popup closes.
The solution is to open the links in an inactive tab i.e. in background.
document.addEventListener('click', evt => {
const a = evt.target.closest('a[href]');
if (a) {
evt.preventDefault();
chrome.tabs.create({url: a.href, active: false});
}
});
Alternatively, open the links in a new window using chrome.windows.create.

How to focus the corresponding tab of an un-docked Chrome debug window?

I often have a lot of tabs open in Chrome browser(s) when developing. I always use the Chrome DevTools un-docked, in a separate window.
Lets say I have opened DevTools for a given tab, then did some search on SO in another tab...
Then if I focus the Chrome DevTools window again, how can I easily find the corresponding browser tab that belongs to this debug window?
I do have a solution, but it is not that straight forward:
in DevTools, go to tab 'Elements'
right-click any element inside the tag
select 'focus' (at the bottom of the list)
This will bring the corresponding browser to the front and will focus the corresponding tab and will focus the selected element.
This is OK but too many steps and forces to leave the current panel in DevTools (need to go to the Elements tab)
I would like a simple shortcut that just focuses the corresponding tab in the browser.

Keep Text in TextArea in Chrome Extension Popup

Chrome extension popups are designed per the FAQ to close when clicked away from.
I have a firefox add-on that will remember the text typed into the text area when the popup is clicked open or closed.
I assume this is the case because the popup merely opens and closes the html, as opposed to the chrome version which calls window.onload each time.
The chrome extension popup however seems to call popup.js each time you click the icon, which I assume is because popup.js is linked from popup.html because page scripts have to be "moved out" in chrome for security.
Is there a way to keep data typed into a textbox, when the extension reloads and "erases" the text?
Anytime the content of the textarea changes, store the new value in localStorage. When the popup loads again, check local storage for a value and populate the textarea.

Firefox not focusing window when opening link in existing window

I have a problem and I think the best thing is to describe it practically:
User is on the main window (this is properly called "main-window" via JavaScript: self.name = "main-window";)
User clicks on a link that opens in a new window
From the new window, user clicks on a link like: <a href="..." target="main-window">
The expected behaviour is the browser to focus on the main window ("main-window") and open the requested page (IE and Chrome do this correctly). Firefox opens the link in the main window, but doesn't focus on it. The result is that the user wonders why the link doesn't work since he doesn't realise that it opens on the window behind the current one.
Is this a known issue? Is there any solution?
Thank you.

popup in Chrome browser action only if click on down arrow on right side of the icon

I am developing a Chrome extension with browser action. I want to make some action on clicking on browser action icon (it is easy, not a problem), and show popup if user clicks on down arrow at the right side of the icon (that is a problem). So, we will receive a functionality similar to the firefox toolbarbutton from XUL. Is it possible to do such thing with Google Chrome?
Just want to make button, like that:
button
If it is pressed on the main part - it will do something, if on the right "drop-down" part - it will show quick settings page.
But I see only single button possibility.
The entire browserAction button works as a single button. There is no way to detect if a specific area was clicked. The best you can do is either have multiple extensions each having their own button for different actions or have options in the popup that the user selects with a second click.