Toggle new tab and popup in options.js - google-chrome-extension

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!

Related

How do you get all visible tabs in chrome?

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.

Can a Chrome extension change its large (new tab page) icon?

My question is along the same lines as this: Change the Chrome extension icon
But I'm wondering instead about the large icon of the extension on a new tab page. Can it change itself based on data? All I have in mind is a simple countdown-calendar (as in, the whole point of the extension is to be a big ol' number on your new tab page), so the actual code wouldn't have to be very long, if icon-changing is possible. (It wouldn't even need to sync or connect to the Internet for any reason.)
My strong hunch is no, because I've never seen an extension do so, and I would expect that if it could, my Chrome's Gmail button would probably display the number of new messages or something. But I figured it didn't hurt to ask.
PS: I've never created a Chrome extension, I just had that idea for one just now. Anyone reading this can feel free to do it themselves, but otherwise I'll make it when I get the time, as a learning exercise.
Only apps (not extensions) can have an icon on the New Tab page (NTP).
This icon have to be declared via the icons property in the manifest file, and cannot dynamically be updated.
I can imagine two ways to get a dynamic icon on the options page:
Create an extension that replaces the New Tab page. Have a look at the docs for Override Pages.
Create an extension that uses the chrome.management API to enable/disable apps. This method might work for your personal setup, but it requires a new App for each icon. This feels a bit hacky, but hey, it might work.

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.

Hyperlink that opens in a new tab but retain focus on the current/parent page

How do you format HTML A tag (when clicked) to make any browser to open it in a new tag, while retaining the focus on the current/parent page?
I know in Firefox, there is an option that says 'When I Open a link in a new tab, switch to the new tab immediately' .. but I want the opposite of this. When a new tab is opened, do not switch. Regardless I check or uncheck this option, it still behaves as I described above.
Anybody faced this before?
Cheers and thanks in advance for your answers,
Lasker
This is a browser setting and you cannot override this from your code and the main thing is
Don't do this.

Resources