Adi B
Adi B

Reputation: 1219

Is there a way of showing/indicating an updated tab from an extension/background page?

I'm looking for behaviour similar to pinned Gmail tabs, where tab head blinks when there's a new email and the tab is not in focus.

chrome.windows.update(..) has a 'drawAttention' option. But chrome.tabs.update(..) only has 'active' and 'highlight' options.

I couldn't locate a method of indicating an updated tab in the active window without switching to it/or highlighting it (which seems to have almost similar behaviour to active).

Upvotes: 1

Views: 389

Answers (2)

Rob W
Rob W

Reputation: 349042

The glowing tab effect is specific to pinned tabs, and only happens when the page's title changes. This feature is not Chrome-specific, it also available in Firefox.

There is no way to get this effect for unpinned tabs, but if the tab is pinned, then you could change the page's title to get the desired effect via content script. To use this, you must declare the permissions to access the host.
Here is minimal example to achieve the goal:

chrome.tabs.executeScript(tabId, {
    'document.title += ".";'
});

If you want to use this feature, I suggest to switch between two states (e.g. with trailing dot and without dot), to prevent the title from getting too long.

Unless the tab content is really updated, I recommend against using this trick, because the visual indicator is misleading when there is no update in the tab.

Alternative ugly ways to draw attentions to unpinned tabs with chrome.tabs.update are:

  • Pin/unpin tab
  • Move tabs across the tab strip
  • Activate/deactive the tab

Upvotes: 2

Xan
Xan

Reputation: 77531

I'm afraid that highlighting is as far as tabs API goes.

You could use a content script to show an annoying animated favicon until the tab gets visible as a possible workaround.

Upvotes: 0

Related Questions