Home > Net >  Show or Hide Extension Icon based on Current Tab
Show or Hide Extension Icon based on Current Tab

Time:11-05

Is there a way to show/hide a chrome extension's icon based on the current tab's URL/location?

I'm writing a utility that I only want to use on certain sites, and I would like to be able to access it in one click while on those sites (i.e. not in the extension overflow menu) but hide it otherwise.

The DeclarativeContent API almost provides what I'm looking for, but it only greys out the icon, rather than hiding it entirely.

Is this possible?

CodePudding user response:

Unfortunately this isn't possible (anymore). Declarative content or not, the presence of your extension's icon near the address bar is only decided by the user by pinning/unpinning it from the extension menu. In older versions of Chrome using chrome.pageAction would result in the extension icon being shown inside the address bar only for the matching websites declared in the manifest. However, things changed a while ago (actually quite some time, maybe >1y, can't recall exactly when): now all extension icons are on the right side outside the address bar and can be pinned/unpinned by the user, meaning they are either always shown or never shown. Pinned icons that use pageAction are greyed out when inactive (see this documentation page).

  • Related