Last active
August 29, 2015 14:10
-
-
Save WiredUK/b0e045f6148c5006a7d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name SE Tab Notifier | |
// @namespace https://gist.github.com/WiredUK | |
// @description Update Tab Title when Inbox has content | |
// @include http://*.stackexchange.com/* | |
// @include http://superuser.com/* | |
// @include http://serverfault.com/* | |
// @include http://meta.stackoverflow.com/* | |
// @include http://stackoverflow.com/* | |
// @include http://stackapps.com/* | |
// ==/UserScript== | |
var script = document.createElement("script"); | |
script.textContent = "(" + grease.toString() + ")()"; | |
document.body.appendChild(script); | |
function grease() | |
{ | |
var newNotifications = $('.network-items a.js-inbox-button .unread-count'); | |
var newReputations = $('.network-items a.js-achievements-button .unread-count'); | |
var oldTitle = $(document).attr('title'); | |
var notifyme = function () | |
{ | |
var notificationCount = newNotifications.text().trim(); | |
var reputationCount = newReputations.text().trim(); | |
if(newNotifications.is(':visible') && newReputations.is(':visible')) | |
{ | |
$(document).attr('title','(' + notificationCount + '/' + reputationCount + ') ' + oldTitle); | |
} | |
else if(newNotifications.is(':visible')) | |
{ | |
$(document).attr('title','(' + notificationCount + ') ' + oldTitle); | |
} | |
else if(newReputations.is(':visible')) | |
{ | |
$(document).attr('title','(' + reputationCount + ') ' + oldTitle); | |
} | |
else | |
{ | |
//Reset back to original title if notifications have gone | |
$(document).attr('title', oldTitle); | |
} | |
}; | |
window.setInterval(notifyme, 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment