9

I really like when running chat in a separate tab you'll see a notification in the tab title.

Now I wonder, what happened with the show-notification-on-events-in-title-bar-for-question-pages ?

I would really like to see that feature, as often one are working with an answer or reading through comments etc. ... sometimes I do my normal work too :) ... so it would be very practical to not have to switch between tabs, or scroll to top, to see if someone replied on a comment or what ever.

Or is there already an existing trick I can do to achieve this?

5
  • Or is there already an existing trick I can do to achieve this? My personal trick is to install the Stack Exchange app on my phone and not keep the device too far. It emits a <s>subtle</s> annoying sound along with a notification when something happens, and the sound alone is enough to know I can investigate. Mar 22, 2016 at 20:59
  • @FrédéricHamidi Thanks,that would be okay for now, though I use Win 10 Mobile so that won't work for me.
    – Asons
    Mar 22, 2016 at 21:06
  • 2
    Interesting. Symmetrically, my Stack Overflow tab is "pinned" in my browser -- it only contains the site's icon. I wouldn't see your title bar notification even if it gets implemented :) Mar 22, 2016 at 21:08
  • 3
    @Frederic the Stack Exchange app has helped me overcome my smartphone addiction. :P The numerous notifications per day first prompted me to silence my phone all day, then I disabled the led and "ambience" (screen lighting up upon notifications) and now at the end of the day I pick up my phone and find plenty of unread mails and missed calls. It's a delight.
    – CodeCaster
    Mar 22, 2016 at 21:26
  • 1
    @FrédéricHamidi If you use my script below, and uncomment the "beeping" part, you will hopefully hear it ... though you might want a less annoying sound :)
    – Asons
    Mar 23, 2016 at 17:19

1 Answer 1

6

While I am waiting for a built in feature, which will work on my Windows 10 Mobile too, I guess this userscript I just made will do for now, running on Chrome on my desktop.

Note, I have only tested it on SO/Meta SO, though it should work other SE sites as well

Updated per ᴉʞuǝ suggestion/comment

// ==UserScript==
// @name           Fixed top menu + Inbox notification + Achievement notification
// @author         LGSon (Fork of Cameron Bernhardt's (AstroCB) "Fixed Stack Exchange Top Bar")
// @version        1.0
// @description    Fixes the top bar of Stack Exchange sites so that it remains at the top
//                 while scrolling and add inbox notification to title bar
// @match          *://*.askubuntu.com/*
// @match          *://*.mathoverflow.net/*
// @match          *://*.serverfault.com/*
// @match          *://*.stackapps.com/*
// @match          *://*.stackexchange.com/*
// @match          *://*.stackoverflow.com/*
// @match          *://*.superuser.com/*
// @exclude        *://api.stackexchange.com/*
// @exclude        *://blog.stackexchange.com/*
// @exclude        *://blog.stackoverflow.com/*
// @exclude        *://chat.stackexchange.com/*
// @exclude        *://chat.stackoverflow.com/*
// @exclude        *://data.stackexchange.com/*
// @exclude        *://elections.stackexchange.com/*
// @exclude        *://stackexchange.com/*
// ==/UserScript==

/* fix top menu while scroll */
var bar = document.getElementsByClassName("topbar")[0];
bar.style.position = "fixed";
bar.style.backgroundColor = "black";
bar.style.zIndex = "12345";
document.getElementById("header").style.paddingTop = "34px";

/* add input notification to title bar */
(function(title,inbox_counter,reps_counter,inbox_value,reps_value) {
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {            
            var pe = mutation.target.parentElement;
            var isInbox = ((' ' + pe.className + ' ').indexOf(' unread-count ') > -1) ? 
                          ((' ' + pe.parentElement.className + ' ').indexOf(' icon-inbox ') > -1) : 
                          ((' ' + pe.className + ' ').indexOf(' icon-inbox ') > -1) ;

            if (mutation.type.toLowerCase() == 'attributes' && window.getComputedStyle(mutation.target,null).getPropertyValue("display") == 'none') {
                if (isInbox) {
                    inbox_value  = '';
                } else {
                    reps_value = '';
                }
            } else {
                if (isInbox) {
                    inbox_value  = '(' + mutation.target.textContent + ') ';
                } else {
                    reps_value = '(' + mutation.target.textContent + ') ';
                }                
            }            
            document.title = inbox_value + reps_value + title;
            /*
            var beep = document.createElement('audio');
            beep.src = 'http://www.soundjay.com/button/beep-24.mp3';
            beep.play();
            delete beep;
            */
        });
    });

    observer.observe(inbox_counter, { attributes: true, childList: true, characterData: true, subtree: true }); 
    observer.observe(reps_counter, { attributes: true, childList: true, characterData: true, subtree: true }); 

    //observer.disconnect();
})(document.title,document.querySelector('.icon-inbox .unread-count'),document.querySelector('.icon-achievements .unread-count'),'','');
5
  • You could adjust those match rules to *://*.stackoverflow.com/* and eliminate the need to define separate rules for the meta sites and they'll work for both protocols http and https.
    – matt.
    Mar 23, 2016 at 17:10
  • @ᴉʞuǝ Thanks for the tip. Will that rule work for sites without sub domains (no www. in front) , like http://serverfault.com/?
    – Asons
    Mar 23, 2016 at 17:16
  • Yes. See this post
    – matt.
    Mar 23, 2016 at 17:18
  • Here is another one on match patterns.
    – matt.
    Mar 23, 2016 at 17:26
  • 1
    @ᴉʞuǝ Answer updated :)
    – Asons
    Mar 23, 2016 at 17:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .