public
Last active

Shows today's reputation score and time till new session begins. Originally written by Nick Craver, maintained by Matt Ball.

  • Download Gist
stackExchangeDailyRep.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
// ==UserScript==
// @name SE Show Today's Reputation
// @namespace SE_TODAY_REP
// @description Shows today's reputation score and time till new session begins. Written by Nick Craver, maintained by Matt Ball. http://meta.stackoverflow.com/questions/12053#57813
// @version 1.1
// @include http://stackoverflow.com/*
// @include http://serverfault.com/*
// @include http://superuser.com/*
// @include http://meta.stackoverflow.com/*
// @include http://*.stackexchange.com/*
// ==/UserScript==
(function() {
function topBar() {
$(function() {
var nav_link = $("#hlinks-nav a:first");
 
if (nav_link.length) {
$("#topbar").css('max-width', '1000px');
var ajaxOpts = {
dataType: 'text',
timeout: 5000
};
 
var profileRepUrl = $('#hlinks-user a.profile-link + a')[0].href + '&sort=post';
 
$.ajax(profileRepUrl, ajaxOpts).success(function(html) {
var $today_rep = $(html).find('td.rep-day:first:contains("today")').prev();
today_rep_int = 0;
if ($today_rep.length) {
today_rep_int = +$today_rep.text()
}
 
var separator = nav_link.parent().prev().find('span:last');
separator.clone().insertBefore(separator);
 
var rep_score = $('<span/>', {
text: ' ' + today_rep_int,
css: {
'font-weight': 'bold',
'font-size': '120%'
}
}).insertBefore(separator);
 
var time_score = $('<span/>', {
'class': 'badgecount'
}).insertBefore(separator);
 
if (today_rep_int >= 200) {
rep_score.css('color', '#BB0000');
time_score.css('color', '#BB8888');
}
 
function timer() {
var now = new Date();
var nextSess = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0 - now.getTimezoneOffset(), 0);
 
if (nextSess.getTime() <= now.getTime()) {
nextSess.setDate(nextSess.getDate() + 1);
}
 
var diff = parseInt((nextSess.getTime() - now.getTime()) / 1000, 10);
 
var hours = parseInt((diff / 3600) % 24, 10);
var minutes = parseInt((diff % 3600) / 60, 10);
var seconds = diff % 60;
 
var settext = GM_fixNumber(hours) + ':' + GM_fixNumber(minutes) + '.' + GM_fixNumber(seconds);
 
time_score.text(' - ' + settext + ' ');
}
 
timer();
 
setInterval(timer, 1000);
});
}
});
 
function GM_fixNumber(num) {
return num < 10 ? '0' + num : num;
}
}
var script = document.createElement("script");
script.textContent = "(" + topBar.toString() + ")();";
document.body.appendChild(script);
})();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.