Created
August 20, 2015 18:00
-
-
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
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 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