So, I’m not much of a music buff, but even I have heard of the music review site Pitchfork. Among my friends, Pitchfork has a reputation for bad reviews, overlooking great albums and praising terrible ones. We talked about it a little in a recent podcast on LoadingReadyRun and I got to thinking that it might be fun to write a user script to manipulate the Pitchfork review scores to bring them more in line with reality. By completely inverting them. I call it Accurate Pitchfork.
Normal:
with Accurate Pitchfork:
In the process of making this script, I had the idea to make a variation that just sets all the scores to 10, so you can imagine a wonderful world where all the music coming out is amazing. I call it Optimistic Pitchfork.
The project ended up being trickier then I thought it would be because Pitchfork.com uses a fancy AJAX page loader, so as you navigate the site, it is only loading new content, not new pages. The way to get around this is a little silly, but I had to have the script monitor all DOM edits so that I could be notified when the content actually changed. I don’t have much experience with Greasemonkey, so if anyone knows a better way to do this, please let me know.
Installation Instructions:
Chrome:
- Click on the link for whichever version you want below
- It will tell you that extensions are dangerous and ask if you are sure, click Continue
- Click install on the confirmation window
- go to pitchfork.com and embrace your new reality
Firefox:
Safari:
Userscripts:
accurate_pitchfork.user.js
optimistic_pitchfork.user.js
Note: I don’t recommend having both scripts enabled at once, it will probably cause unexpected wierdness.
For those of you interested in seeing how the script works, the full source is after the jump:
Source of accurate_pitchfork.user.js
// ==UserScript==
// @name Accurate Pitchfork
// @namespace http://somewhatnifty.com
// @description Inverts all Pitchfork review scores
// @include http://pitchfork.com/*
// ==/UserScript==
document.body.addEventListener("DOMNodeInserted",function(event){ //pitchfork uses funky AJAX page loads, so monitor the DOM for changes
var element = event.target;
if(typeof element.className !== undefined && element.className != '' && element.className != null) {
if(element.className.substr(0,5) == 'info') { //a known element that isn't loaded until the end of the page
scores = document.getElementsByClassName('score');
if(scores.length >0){
for (i in scores) {
score = scores[i];
class_parts = score.className.split(/\W/);
curr_score = class_parts[class_parts.length-2] + class_parts[class_parts.length-1];
new_score = 100 - curr_score; //invert score
new_score = new_score.toString();
new_score_int = new_score.slice(0,-1);
new_score_dec = new_score.slice(-1);
score.className = 'score score-'+ new_score_int + '-' + new_score_dec;
score.innerHTML = new_score_int + '.' + new_score_dec;
}
}
}
}
},false);
Comment (1)