Add rank % greasemonkey script

This forum contains information about 3rd party applications which may be of use to those who run the FAH client and one place where you might be able to get help when using one of those apps.

Moderator: Site Moderators

Post Reply
wkbaran
Posts: 1
Joined: Sat Jan 02, 2016 4:18 pm

Add rank % greasemonkey script

Post by wkbaran »

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. :)

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)+"%)");
});
Post Reply