Created
November 19, 2012 07:20
-
-
Save AndrewRayCode/4109402 to your computer and use it in GitHub Desktop.
Print relevant data from OKC's My Best Face
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
/** | |
* Go to the "see all votes" section of the report, then | |
* paste this script into your console. It will show you actual | |
* vote counts for your images. "Normalized" OKC data is BS and | |
* misleading. Don't be fooled! | |
*/ | |
var imgs = document.querySelectorAll('img[title="An image of you"]'),i=0,img,badge, | |
badges = document.querySelectorAll('div.badge'), | |
prev = imgs[0].getAttribute('src'), | |
fr = 0, total=0; | |
var div = document.createElement('div'),totals=[]; | |
div.setAttribute('style', 'padding:20px 10px 20px 20px;background:#eee;font-size:20px;color:red;float:left;'); | |
document.querySelector('div.main').insertBefore(div, document.getElementById('content')); | |
for(; badge=badges[i]; i++) { | |
total++; | |
if((imgs[i].getAttribute('src') !== prev) || (i === badges.length - 1)) { | |
totals.push({html: | |
'<div style="float:left;padding:10px;width:170px;text-align:center;background:#ddd;margin:0 10px 0 0;">' + | |
'<img src="'+prev+'">'+fr+' / '+((total +(i===badges.length-1)) - 1)+'</div>', | |
score: (fr / ((total +(i===badges.length-1)) - 1)) | |
}); | |
fr=0; | |
total=1; | |
prev = imgs[i].getAttribute('src'); | |
} | |
if(imgs[i] === badge.previousSibling.previousSibling) { | |
fr++; | |
} | |
} | |
totals = totals.sort(function(a,b) {return a.score < b.score;}); | |
div.innerHTML = totals.map(function(i) {return i.html;}).join(''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment