Skip to content

Instantly share code, notes, and snippets.

@JJ
Created April 20, 2013 09:43
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 JJ/5425425 to your computer and use it in GitHub Desktop.
Save JJ/5425425 to your computer and use it in GitHub Desktop.
GreaseMonkey script that puts on top of the citation graph the actual number of citations per year; works on the Google Citations page. In old versions of Chrome and Chromium this should work without a problem. In new versions you'll have to get out of your way to install it, so don't bother and just switch to Firefox and install the GreaseMonke…
// ==UserScript==
// @name gcitations
// @namespace http://merelo.net/gmscripts
// @description Compute number of citations per year in Google Citations
// @include http://scholar.google.com/citations*
// ==/UserScript==
var imgs = document.getElementsByTagName('img');
var my_url;
var my_img;
for ( var i = 0; i < imgs.length; i ++ ) {
if ( imgs[i].src.match(/chart\?chs/)) {
my_url = imgs[i].src;
my_img = imgs[i];
}
}
var params = my_url.split(/&/);
var max;
var citations;
for ( var p in params ) {
var values = params[p].split(/=/ );
if ( values[0] == 'chxr') {
var maxes = values[1].split(/,/);
var max = maxes[2];
}
if ( values[0] == 'chd') {
var tsplit = values[1].split(/:/);
citations = tsplit[1].split(/,/);
}
}
var numbers = '';
for ( c = 0; c < citations.length; c++ ){
numbers += Math.round(citations[c]*max/100);
if ( c < citations.length -1 ) {
numbers += ", ";
}
}
var text = document.createTextNode(numbers);
my_img.parentNode.insertBefore(text,my_img);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment