Skip to content

@mjball /stackExchangeDailyRep.user.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Shows today's reputation score and time till new session begins. Originally written by Nick Craver, maintained by Matt Ball.
// ==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);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.