Add rank % greasemonkey script
Posted: Sat Jan 02, 2016 4:32 pm
Hi,
I wanted to see the rank % on the user stats for no particular reason so here's the following greasemonkey script to add it.
It was quicker and easier than asking for the change.
I wanted to see the rank % on the user stats for no particular reason so here's the following greasemonkey script to add it.
It was quicker and easier than asking for the change.
Code: Select all
// ==UserScript==
// @name FaH User rank
// @namespace http://folding.stanford.edu/
// @version 0.1
// @description Add rank % to FaH user detail page
// @author Bill Baran
// @match http://fah-web.stanford.edu/cgi-bin/main.py?qtype=userpage&username=*
// @grant none
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// ==/UserScript==
/* jshint -W097 */
'use strict';
// Your code here...
$(document).ready(function() {
var fullSelector = "body > font > table > tbody > tr > td > table:nth-child(12) > tbody > tr:nth-child(4) > td:nth-child(2) > font";
var rankSelector = fullSelector + " > b";
var rank = $(rankSelector).html().match(/\d+/)[0];
var ttlStr = $(fullSelector).html();
var ttl = ttlStr.match(/\d+/g)[1]
var prct = rank/ttl*100;
var rank = $(rankSelector).html(rank+" (top "+prct.toFixed(4)+"%)");
});