Skip to content

Instantly share code, notes, and snippets.

@mwerner
Created January 16, 2015 20:46
Show Gist options
  • Save mwerner/d0434e07f35f30a61813 to your computer and use it in GitHub Desktop.
Save mwerner/d0434e07f35f30a61813 to your computer and use it in GitHub Desktop.
.js in your github
var today = new Date();
var ago = today - 1000 * 60 * 60 * 24 * 1;
var yesterday = new Date(ago);
var dd = yesterday.getDate();
var mm = yesterday.getMonth() + 1;
var yyyy = yesterday.getFullYear();
if (dd < 10){ dd = '0' + dd }
if (mm < 10){ mm = '0' + mm }
date = yyyy+'-'+mm+'-'+dd;
[{
tooltip: 'Your Pull Requests',
icon: 'git-pull-request',
url: 'https://github.com/pulls',
position: 1
},{
tooltip: 'Mentioning @mwerner',
icon: 'mention',
url: ('https://github.com/pulls?q=is%3Aopen+is%3Apr+mentions%3Amwerner+updated%3A>' + date),
position: 2,
notifications: true
},{
tooltip: 'Trending Ruby Libraries',
icon: 'ruby',
url: 'https://github.com/trending?l=ruby',
position: 3
},{
tooltip: 'Your Conversations',
icon: 'comment-discussion',
url: ('https://github.com/pulls?q=is%3Apr+is%3Aopen+commenter%3Amwerner+updated%3A>' + date),
position: 4,
notifications: true
}].forEach(function(i){
$('<li class="header-nav-item"> \
<a href="'+i.url+'" class="notification-indicator header-nav-link tooltipped tooltipped-s" aria-label="'+i.tooltip+'"> \
<span class="octicon octicon-'+i.icon+'"></span> \
</a> \
</li>').insertAfter('#user-links .header-nav-item:nth-child('+i.position+')');
if (i.notifications) {
$.ajax({ url: i.url }).done(function(data) {
var html = $.parseHTML(data);
var items = $('.table-list-item', html);
if (items.length == 0) { return; }
var shortcut = $('a[href="' + i.url + '"]');
shortcut.prepend('<span class="mail-status unread"></span>');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment