Skip to content

Instantly share code, notes, and snippets.

@shu8
Created August 20, 2015 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shu8/21ef0ba0b2b88be5a347 to your computer and use it in GitHub Desktop.
Save shu8/21ef0ba0b2b88be5a347 to your computer and use it in GitHub Desktop.
Adds the number of bounties someone has offered/earned to the tab names on their profile page
// ==UserScript==
// @name Bounty count on user profile page
// @namespace http://stackexchange.com/users/4337810/
// @version 1.0
// @description Adds the number of bounties someone has offered/earned to the tab names on their profile page
// @author ᔕᖺᘎᕊ (http://stackexchange.com/users/4337810/)
// @match *://*.stackexchange.com/users/*
// @match *://*.stackoverflow.com/users/*
// @match *://*.superuser.com/users/*
// @match *://*.serverfault.com/users/*
// @match *://*.askubuntu.com/users/*
// @match *://*.stackapps.com/users/*
// @match *://*.mathoverflow.net/users/*
// @grant none
// ==/UserScript==
function getCounts(tab, callback) {
$.get($(location).attr('href').split('?')[0]+"?tab=bounties&sort="+tab, function (x,y,z) {
callback($(x).find('div.subheader.user-full-tab-header > h1 > span.count').text());
});
}
function addCounts() {
var offered = getCounts('offered', function (offered) {
var earned = getCounts('earned', function(earned) {
$('body').find('#user-panel-bounties > div.subheader > div a[data-sort-id="offered"]').text("offered ("+offered+")");
$('body').find('#user-panel-bounties > div.subheader > div a[data-sort-id="earned"]').text("earned ("+earned+")");
});
});
}
$(document).on('click', '#user-panel-bounties > div.subheader > div a', function() {
addCounts();
});
addCounts();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment