<!-- thumbnail: https://i.sstatic.net/zovko.png -->
<!-- version: 1.06 -->
<!-- excerpt: Provides a fully functional top bar, including realtime notifications, at the top of all chat rooms. Keep tabs on your inbox and site activity while chatting. Can even match the chat theme. -->
<!-- https://stackapps.com/q/2985 -->

Description:
-

Provides a fully functional top bar, including realtime notifications, at the top of all chat rooms. Keep tabs on your inbox and site activity while chatting.

[![enter image description here][1]][1]

[![enter image description here][2]][2]

Can also match the chat room's theme (beta):

[![enter image description here][3]][3]

---

Download:
-

- [Github][4]
- [Github raw][5]

Features:
-

- Fully functional with dropdowns and realtime notifications.
- Does not require additional authentication or access tokens.
- Topbar background can match chat room theme (beta, must be activated through console right now).
- To configure settings, click the "topbar" link in the footer:

  [![enter image description here][6]][6]



Console Usage:
-

Some options are settable through the console via the `ChatTopBar` object. All options set will be saved. The following console commands are available:

- `ChatTopBar.setWiden(boolean)`: True to use 95% width, false to use default width.
- `ChatTopBar.setThemed(boolean)`: True to make the topbar match the current chat room's theme, false to use the default dark background.
- `ChatTopBar.setBrightness(float)`: Set brightness of icons and text in topbar (1.0 is default). This setting is saved per room, and is only applied when themes are enabled. Can help deal with themes that don't contrast well with the icons.
- `ChatTopBar.setQuiet(boolean)`: True to suppress console output.
- `ChatTopBar.forgetAccount()`: Forget cached network account ID, useful for testing.
- `ChatTopBar.forgetEverything()`: Erase all persistent settings, useful for testing.
- `ChatTopBar.dumpSettings()`: Print all persistent settings, useful for testing.
- `ChatTopBar.fakeUnreadCounts(inbox,rep)`: Fake unread item messages to show indicators, useful for testing and photo ops.

Notes:
-

- Uses one API query to get account ID. However, this value is cached, so usage should be extremely minimal. This is the only thing it uses the API for, so your quota should be safe.
- I wasn't sure what to do with the search box so I left it as-is: The top bar search searches all chat, the sidebar search searches the current room. 
- Mad props to [Gerry][7] and [Shog9][8] for helping me figure stuff out.

Issues:
-

- **Currently does not work on Firefox.** I'm running into all kinds of problems with GreaseMonkey, and event handlers not being called, and sandboxing, scope, jQuery, etc. There's a branch at https://github.com/JC3/SEUserScripts/blob/firefox-greasemonkey/ChatTopBar.user.js that I'm doing Firefox work on, if anybody has any insight, it'd be greatly appreciated.
- Initial state of notification / reputation unread counts *may* be inaccurate due to [fundamental issues with the topbar on chat](https://meta.stackexchange.com/questions/296714/inbox-reputation-notifications-do-not-work-on-chat-server-top-bar). See also the source comments.
- Not thoroughly tested yet. Please post bugs and requests here or on Github (or ping me in [The Tavern](http://chat.meta.stackexchange.com/rooms/89/tavern-on-the-meta))!

Change Log:
-

- [1.07][9]
  - Settings dialog (accessible from 'topbar' link in footer).
  - Wide mode now matches right side padding instead of fixed at 95%.
  - More descriptive search box placeholders.
  - `ChatTopBar.forgetEverything`, for testing.

- [1.06][10], [+][11]
  - Brightness now only applied if theme enabled.
  - Sidebar resized so it doesn't hide behind the bottom panel.
  - `ChatTopBar.fakeUnreadCounts(inbox,rep)` for debugging.
  - Explicit `unsafeWindow` grant.
  - Sort output of `dumpSettings()`.

- [1.04][12], [1.05][13]
  - Per-room icon/text brightness option.
  - Option to suppress console output.
  - Ability to dump settings to console for testing.
  - Fixed a style bug where things were happening before CSS was loaded, was sometimes causing non-themed topbar to have a white background instead of black.

- [1.03][14]
  - `ChatTopBar` console interface for setting options.
  - Widen / theme options now user-settable.
  - Ability to forget cached account ID for testing.

- [1.02][15]
  - WebSocket reconnect when connection lost.
  - Beta code for themed topbar.
  - Better console logging.

- [1.01][16]
  - Realtime event handling via websocket.

- [1.00][17]
  - Initial version.

---

[Check out my other scripts.](https://stackapps.com/search?tab=active&q=user%3a25350%20is%3aq%20%5bscript%5d%20)


  [1]: https://i.sstatic.net/XSOgp.png
  [2]: https://i.sstatic.net/SHP6h.png
  [3]: https://i.sstatic.net/6OOLs.png
  [4]: https://github.com/JC3/SEUserScripts/blob/master/ChatTopBar.user.js
  [5]: https://github.com/JC3/SEUserScripts/raw/master/ChatTopBar.user.js
  [6]: https://i.sstatic.net/AveWV.png
  [7]: https://stackexchange.com/users/4412195/gerry
  [8]: https://stackexchange.com/users/620/shog9
  [9]: https://github.com/JC3/SEUserScripts/commit/f10da173bdafba4905c968d58009da270ff887ba
  [10]: https://github.com/JC3/SEUserScripts/commit/418095c3b314e8b006f9c4617003ca5bcac7cef5
  [11]: https://github.com/JC3/SEUserScripts/commit/0ccfea90393be203e663767b6303bcb3bbcefb50
  [12]: https://github.com/JC3/SEUserScripts/commit/6d46495b0d0d9afcc7157ba5a881389df7493ca2
  [13]: https://github.com/JC3/SEUserScripts/commit/16acda08b8fd7ca153f253b92c0e90da93b4ddea
  [14]: https://github.com/JC3/SEUserScripts/commit/e08bba173017edc9110b9f20c71b808e04109025
  [15]: https://github.com/JC3/SEUserScripts/commit/f126351b0731c7269851a7651f540cf69958f866
  [16]: https://github.com/JC3/SEUserScripts/commit/1fc6bf9bbb135e5b4514f0723e99f407b53bf7e8
  [17]: https://github.com/JC3/SEUserScripts/commit/b29a9dc53affd60cfbb661a0b498353c1ca01258