How do you get all visible tabs in chrome? - google-chrome-extension

I need to get the tab ids of all VISIBLE tabs in chrome. Note that this is different from currently active tabs or current tab. The user will have the current tab visible, but may have another chrome browser window in the background that may be visible on screen but won't be the current tab. I need the id of that tab as well, and all tabs like it. How can I do this? Can I do this in a way that minimizes permission use (Only using activeTab if possible).

I think that first you have to retrieve all the chrome instances.
you can do this with getAll method.
Then you can loop over all instances and for each look for the active tabs.
there is a SO answer related to this, which may help

You can use chrome.tabs.query.

Related

How to take screenshot of a tab in chrome extension

I am adding screenshot support to my extension, I want to take screenshot of a tab when a specific event is triggered, for example, a url is accessed. Now I am able to take screenshot of current tab using chrome.tabs.capturevisibletab, but the problem is that the event can be triggered by a tab that is not currently visible. So instead of visible tab, how can I take screenshot of any specific tab?
The method name is clear: capturevisibletab.
You can put the focus on the tab you want to snapshot, invoke the method and the restore the focus on the previous tab though.
You will need to add the <all_urls> permission in your manifest file.

Toggle new tab and popup in options.js

I was curious to see if anyone had any experience with allowing the user to turn off or on the new tab chrome_url_override.
I am currently developing an extension that loads the content when a new tab is opened, but would also like to have the option of turning the new tab functionality off and allowing the user to use the extension as a popup located on the toolbar.
I would prefer not to separate this between two extensions, so if anyone has done or seen anything like this that would be a tremendous amount of help.
Nope! you will need to do it manually, unfortunately. If it helps, the new tab returns www.google.com with location.hostname so your scripts could use this to detect a new tab.
Hope it helps!

Feasibility of grouping tabs in Chrome

I'd like to be able to group tabs in Chrome (on Windows Vista/7 primarily), as I can with Tab Mix Plus on Firefox, so that I only see one group in the tab list at one time. I don't seem to be the only one, but it hasn't been done, so far as I can tell. There are plenty of tab managers out there, like TooManyTabs and Tab Outliner, which summarise, save and unload tabs, but they don't leave them loaded whilst hiding them.
I've not coded a Chrome extension before, but I think the specific problem is that you can't control the visibility of tabs (in the way you can with the hidden attribute of tabs in Firefox) or windows from a Chrome extension. Is that right, or have I missed something in the API?
If that is right, any way anyone can see to hack round this? Put the tabs I want invisible in a window and then use whatever Windows API allows http://www.hide-window.com/ to hide that window?

Can I hide my extension's icon by default?

My Chrome extension doesn't need an icon - it's a one-liner extension that doesn't want to take up space on your extension bar.
How can I hide the icon by default?
Due to a change spearheaded by Google, all extensions now must have an icon in the toolbar area or the "overflow" in the menu.
Even if you don't have a browser_action, your extension will display an icon (or failing that, a tile with extension name's first letter). If you do not declare a browser_action, it will be greyed out and non-interactive, but will still be there.
The idea of this change is to provide visibility of otherwise potentially stealthy extensions ("Hey user, did you even know you have those installed?"). It's, let's put it, debatable whether it's the best approach, but that was Google's decision.
To suppress this behavior, add "converted_from_user_script": true to the extension's manifest.json. This works as of Chrome 61.
It used to be that visiting a link to a user script (ending in .user.js) caused Chrome to package up the user script as a content script extension with a generated manifest which included the converted_from_user_script key. Of course, this no longer works because all extensions (except in developer mode) now have to come from the Chrome Web Store.
Google thought it best to make the icon mandatory and I think so too, for reasons already pointed out by Xan.
Now of course you 're right, when you say that many extensions have no need for an icon, but the requirement of one still gives your extension an identity and Google still gives the user the opportunity to remove it from the toolbar. He simply has to right click the extension's icon and then choose Hide in Chrome menu.
I know, many users don't really bother to read all of the options under right click, or even right click it at all. But most of them still will make a single left click, to see if there is any option in the fancy new extension they added. You can take advantage of this by making a simple window where you point out their option of hiding the icon.
If you don't want an icon, you can omit the browser_action parameter from your manifest.json (the default_icon option is where you usually specify the icon). The browser_action section is what controls what you see in the toolbar.

Any way to remove X button from chrome tabs?

Is there any way to modify chrome tabs to remove the button that closes the tab?
I've read through chrome develope tab. but I don't see any mention of the close button.
Not possible at the moment without forking the whole chromium project. See bug report #50913 (Status: WontFix).
Possible workarounds:
If you right click on a tab you can Pin Tab. This will remove the close button but you can still close it with ctrl+w. Unfortunately, this will also remove the window title.
The close button is removed if the width of the tab gets very small.
Have a look at the same question on SuperUser: How to disable the close (X) button on Google Chrome tabs?.
Maybe you like to look at the source code of Chromium and fix this? I think you have to start here: tab.cc.
Edit: The fix below only worked between Chrome version 69 and 71.
It IS possible now for inactive tabs!
I have had lots of problems while trying to switch tab while having 10-15 of them opened, accidentally closing some important tab with lots of text typed which isn't recovered by Ctrl+Shift+T
Here how to do that:
1) Open the Google Chrome browser and type the following text into the address bar:
chrome://flags/#close-buttons-inactive-tabs
This will open the flags page directly with the relevant setting.
2) Set the option named Close buttons on inactive tabs. Set it to Disabled using the drop down list next to the flag's name.
3) Restart Google Chrome by closing it manually or you can also use the Relaunch button which will appear at the very bottom of the page.
4) The close buttons will disappear from inactive tabs.
Before:
After:
That's it!
Source - https://winaero.com/blog/remove-close-buttons-inactive-tabs-google-chrome/
There are now Chromium-based alternative browsers which offer this - I really like Vivaldi, where not showing the X button is just one of many customization options. Also, because it is Chromium based you can install and use any Chrome extensions. It is perfect if you have many tabs open and need more of the power-user type options.

Resources