Skip to content

Instantly share code, notes, and snippets.

@kylestev
Created November 16, 2012 20:31
Show Gist options
  • Save kylestev/4090641 to your computer and use it in GitHub Desktop.
Save kylestev/4090641 to your computer and use it in GitHub Desktop.
Pandora functions
function clickButton(className, index) {
var buttons = document.getElementsByClassName(className);
console.log(buttons);
if (index < buttons.length) {
buttons[index].click();
}
}
function getCurrentTrack() {
this.isThumbed = function(direction) {
var thumb = document.getElementById("thumb" + direction);
return thumb != null && thumb.attributes['style'].value.indexOf("none") == -1;
}
this.songInfo = function(className) {
var nodes = document.getElementsByClassName(className);
return nodes != null && nodes.length > 0 && nodes[0].innerText;
}
return {
songTitle: this.songInfo("songTitle"),
songArtist: this.songInfo("artistSummary"),
albumTitle: this.songInfo("albumTitle"),
isThumbedUp: this.isThumbed("up"),
isThumbedDown: this.isThumbed("down"),
playSong: function() { clickButton("playButton", 0); },
pauseSong: function() { clickButton("pauseButton", 0); },
thumbUpSong: function() { clickButton("thumbUpButton", 0); },
thumbDownSong: function() { clickButton("thumbDownButton", 0); }
}
}
function getCurrentStationTitle() {
var nodes = document.getElementsByClassName("stationListItem selected");
return nodes != null && nodes.length > 0 && nodes[0].children[0].children[0].children[0].innerText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment