Skip to content

Instantly share code, notes, and snippets.

@Ruxton
Created August 15, 2011 03:19
Show Gist options
  • Save Ruxton/1145657 to your computer and use it in GitHub Desktop.
Save Ruxton/1145657 to your computer and use it in GitHub Desktop.
Blocks clicks in them itms link maker, re-creates metadata and captures output
$('a.link').unbind( 'click' );
$('a.link').bind( 'click', function(event) {
event.preventDefault();
event.stopPropagation();
var f = this.className.replace(/(\s|^)link(\s|$)/, "");
this.mediaType = f.substr(0, 1).toUpperCase() + f.substr(1);
if (this.mediaType == "Artist") {
this.linkText = $(this).prevAll("h5").text() + " (Artist)";
this.artistText = "<strong>" + this.linkText + "</strong>"
} else {
if (this.mediaType == "Movie" || this.mediaType == "Podcast" || this.mediaType == "Film") {
this.name = $(this).closest("tr").find("td.name > span").text();
this.linkText = this.name;
this.artistText = "<strong>" + this.linkText + "</strong>"
} else {
if (this.mediaType == "Video") {
this.name = $(this).closest("tr").find("td.name > span").text();
this.artist = $(this).closest("tr").find("td.album_genre > span").text();
this.linkText = this.artist + " - " + this.name;
this.artistText = "<strong>" + this.artist + "</strong>" + " -" + this.name;
} else {
this.name = $(this).closest("tr").find("td.name > span").text();
this.artist = $(this).closest("tr").find("td.album_artist > span").text();
this.linkText = this.artist + " - " + this.name;
this.artistText = "<strong>" + this.artist + "</strong>" + " - " + this.name;
}
}
}
url = this.href;
title = '';
if(this.linkText)
{
title = this.linkText;
}
console.log("Title: "+title+" URL: "+url);
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment