// ==UserScript==
// @name Show My Pitchfork Score & Search in Spotify
// @namespace http://your.homepage/
// @version 0.2
// @description Get the score of each album on the overview of the reviews & get a link to search album on Spotify
// @author CyanideCentral, Cisco
// @match https://pitchfork.com/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// @downloadURL https://update.greasyfork.cloud/scripts/414901/Show%20My%20Pitchfork%20Score%20%20Search%20in%20Spotify.user.js
// @updateURL https://update.greasyfork.cloud/scripts/414901/Show%20My%20Pitchfork%20Score%20%20Search%20in%20Spotify.meta.js
// ==/UserScript==
var scoreDiv= document.createElement('div');
scoreDiv.id='score';
$('body').append(scoreDiv);
$('#score').hide();
function addSAS() {
var recall= setInterval(function(){
if($('a[href^="/reviews"] > .artwork').length >= 1) {
clearInterval(recall);
$('a[href^="/reviews"] > .artwork:not(.with-score)').each(function(){
var artwork= $(this);
artwork.addClass('with-score');
var targetURL= artwork.parent().attr('href');
$('#score').load(targetURL + ' .score', function() {
var scoreThis= $('#score > span').text();
var artist= $.trim(artwork.next().children('h1').text().replace(/[\s\']/g, '+'));
var album= $.trim(artwork.next().children('h2').text().replace(/[\s\']/g, '+'));
artwork.append('' + scoreThis + '');
if(artwork.next().next('.p4ktag').length > 0) {
//artwork.children('.scrapped-score').addClass('bnm');
}
artwork.append(' ');
}); // End of LOAD
}); // End of EACH
}
}, 1000);
} // End of Function addSAS()
function checkURLChange(URL) {
if(URL !== document.location.href) {
currURL= document.location.href;
addSAS();
}
} // End of function CheckURLChange()
// INIT
addSAS();
var currURL= document.location.href;
setInterval(function() {checkURLChange(currURL);}, 1000);
var cssRules= '';
$('head').append(cssRules);