Pitchfork Reviews to Amazon Reviews

By jadi Last update Jan 10, 2009 — Installed 57 times. Daily Installs: 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

There are 2 previous versions of this script.

// ==UserScript==
// @name           Pitchfork Reviews to Amazon Reviews
// @namespace      http://amzn1995.googlepages.com
// @description    Adds links on Pitchfork reviews to corresponding Amazon mp3s and reviews.
// @include        http://www.pitchforkmedia.com/article/record_review/*
// ==/UserScript==


function create_li(link_text,search_url,keywords) {
  var text = document.createTextNode(link_text);
  var link = document.createElement('A');
  var li = document.createElement('LI');

  link.href = search_url+keywords;
  link.appendChild(text);
  li.appendChild(link);

  return li;
}

function $(id){ return document.getElementById(id); };

function find_artist_album() {
	var info = $('main').childNodes[1].childNodes[1].childNodes[2].innerHTML;
	var artist = info.split("<br>")[0].replace(/:/,'').replace(/^\s+/,'');
	var album = info.split("<br>")[1].replace(/^\s+/,'');
	return {'artist':artist,'album':album};
}


var amazon_mp3_url = 'http://www.amazon.com/s?url=search-alias%3Ddigital-music&field-keywords=';
var amazon_cd_url = 'http://www.amazon.com/s?url=search-alias%3dpopular&field-keywords=';

var keywords = find_artist_album();

var pitchfork_buy_ul = document.getElementsByClassName('buy')[0];

if (keywords){
	pitchfork_buy_ul.appendChild( create_li('Amazon reviews of '+keywords.album, amazon_cd_url, keywords.artist+'+'+keywords.album) );
	pitchfork_buy_ul.appendChild( create_li(keywords.artist+' Amazon MP3 dowloads', amazon_mp3_url, keywords.artist) );
}