Can I hide my extension's icon by default? - google-chrome-extension

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.

Related

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?

Configurable keyboard shortcut without using content scripts

Chrome Extension: I am looking for a way to assign global keyboard shortcuts that can be invoked even when the current tab has no content (and hence no content script). Some examples of such tabs: 'new tab' tabs, chrome://extensions tabs, 'page not loaded' tabs, etc Use cases for such a requirement are operations like close tab, go to next/prev tab, etc.
The chrome.commands api allows one to do this. However, there seems to be no way for the user to configure these keyboard shortcuts, which is something I'd really want my extension to allow.
Is there any way to get configurable keyboard shortcuts that don't need a content script?
The shortcut for chrome.commands cannot be changed by the extension, but it is configurable by the user. This interface is built-in and offered by Chrome itself.
Visit the extensions page, scroll down and click on the Configure commands link. A box will be shown, where the user can set the preferred shortcut:
The code for the "Remap shortcut" extension is posted in this answer.

Inspect popup for extensions removed; debug console eating extension form element inputs

To debug extensions, Chrome used to have a "Inspect popup" menu option available when right clicking the extension icon (top right in the browser). I believe this options was recently removed (possibly with the latest Chrome version 20, which I am using) .
The debug console can still be activated by right clicking any element in the extension popup and selecting "Inspect element". The problem I am experiencing however is that whenever I now have the debug console open, typing into form elements in the popup does not work. Even though the form element seems to have the focus (it has a blinking cursor active), all input typed goes straight to the debug console.
Update: It seems focus is not specifically to the debug console, but to whichever window is below. It's like the extension window is a "stay on top" window, without capturing any input.
Update: 2012-07-24: Updated to 22.0.1215.0 (Official Build 147830) dev and the bug is still there. But yay, Youtube full screen now suddenly works on my dual screen system!
Update 2012-05-09: Upgraded from 20.0.1123 to 20.0.1130.1 dev on Linux x64 (Ubuntu 12.04). Problem still there, and makes debugging extensions a lot harder than needs be. Also confirmed behaviour on older Chrome release (20.0.1105.0). Oh well, maybe it's just me...
Update 2012-05-09 2: Assuming this is a bug, consider adding a background page to your popup and log to that page's console instead until bug gets fixed. At least that makes my life easier for now.
Update: 2012-10-19: As omri writes (and points to), the Inspect Popup option is on it's way to be put back into Chrome, which will hopefully solve this problem (finally).
Could anybody confirm/deny this behavior, and/or suggest possible workarounds?
Open the popup
Right click the popup window and inspect.
Its going to be re-added to chrome
http://code.google.com/p/chromium/issues/detail?id=143349
Update: Un-accepting answer as another user confirmed this behaviour for OSX, so at least it will appear as unsolved on the radar, although there's probably a bug tracker somewhere where this needs to be posted.
This bug is still present on google-chrome-beta (Version 20.0.1132.34 beta). I'm guessing that this has to do with window and popup handling on X11 generally, and is obviously not a high priority bug since it's remained this way for quite a few releases. Closing question.
I am seeing the missing "Inspect Popup" option on right click but, I can edit/enter text in the form fields.
I am wondering if you are having an unrelated problem? If you are using or updating to the new 2.0 Extension Manifest you can encounter issues where inline javascript in the popup fails to fire any longer because of the addition of the content_security_policy defaults. Basically this prevents script injection but also seems to kill all JS in your popup. There are ways around this by changing the way events are handeled in your popup or by changing the default policy. Here's a link to the doc on this: http://code.google.com/chrome/extensions/contentSecurityPolicy.html
This is just a guess because I don't know what's going on in your code but I saw similar things while upgrading my extension recently.
Just upgraded to 22.0.1221.1 (Official Build 149058) dev and the problem seems to have been solved, albeit with a workaround. The old way of right clicking in the popup window and selecting "Inspect Element" to start up the console still grabs all input as originally reported.
However, it seems by right clicking the popup icon, the old "Inspect Popup" seems to be back, and when this is used it does not seem to grab input from the open popup window itself.

Browser Context Menu customization?

Is there a way to override the "undo" and "select all" in right click context menu of the browser over textarea?
Thank you.
You cannot edit the browser's built-in context menu, but you can disable it and replace it with your own using the oncontextmenu event on the window object. I would caution that this is often a bad idea. Users expect to find the built-in context menu and are often frustrated when it isn't there.
I know you can prevent the whole context menu from opening by registering to the click() event, doing some cross-browser mumbo-jumbo to get wich button was clicked, and then return false if the right one was clicked.
However, I don't think it's possible to modify the context menu itself, at least not using javascript.
I should add that you may want to rethink why you're doing this. This will never be a protection against anything (some try to prevent copying images from their website), as it may simply be disabled by turning javascript off.
UPDATE: Ok, so you don't want to prevent users to do things, bug have them doing things your way. Then, I guess the best thing to do is :
Provide users with a toolbar that allow them to do these things (and thus making them use your actions instead of the default one
Map the usual keyboard shortcuts to your actions (Ctrl+A, Ctrl+Z, etc...)
Replace the right click menu with your own.
You mentionned in another comment that you cannot reproduce copy/paste, which is correct, but you can implement you own clipboard (that will only work for your webapp) if you really have to.

Resources