<commit_before>
/*
 * Chrome-Last.fm-Scrobbler amazon.com "new interface" Connector
 *
 * <NAME> --- http://sheckel.net --- jacob[at]sheckel[dot]net
 *
 * Derived from Pandora module by <NAME>
 */

/********* Configuration: ***********/

// changes to the DOM in this container will trigger an update.
watchedContainer = "div.nowPlayingDetail";

// changes to the DOM in this container are due to play/pause/forward/back
playerMasterControl = "div.mp3Player-MasterControl";

// function that returns title and artist of current song
function titleAndArtist() {
  var nowPlayingTableRow = $("tr.selectable").has("a.nowPlaying");
  return {
    title: nowPlayingTableRow.children("td.titleCell").attr("title"),
    artist: nowPlayingTableRow.children("td.artistCell").attr("title")
  }
}

/**
 * Takes raw string, checks that it is in the form "xx:xx", and
 * calculates and returns the number of seconds, otherwise returns
 * -1 indicating failure to parse.
 */
function parseTime (maybeTime) {
  if (typeof(maybeTime) == "string" && maybeTime.indexOf (":") > 0) {
    var timeArr = maybeTime.split(":");
    return parseInt(timeArr[0])*60 + parseInt(timeArr[1]);
  } else {
    return -1;
  }
}

function currentTimeAndTrackDuration () {
  var songStatusTimer = $(".currentSongStatus .timer");
  return {
    currentTime: parseTime(songStatusTimer.find("#currentTime").html()),
    trackDuration: parseTime(songStatusTimer.children().filter(":last").html())
  }<commit_msg>issue #81 bug fix - safety net if user navigates away from main panel, fall back to (possibly truncated) now playing info<commit_after>
/*
 * Chrome-Last.fm-Scrobbler amazon.com "new interface" Connector
 *
 * <NAME> --- http://sheckel.net --- jacob[at]sheckel[dot]net
 *
 * Derived from Pandora module by <NAME>
 */

/********* Configuration: ***********/

// changes to the DOM in this container will trigger an update.
watchedContainer = "div.nowPlayingDetail";

// changes to the DOM in this container are due to play/pause/forward/back
playerMasterControl = "div.mp3Player-MasterControl";

/**
 * Function that returns title and artist of current song.
 * Make best effort to get the full, untruncated values from the
 * main cloud player pane. But, the user may have navigated away
 * from that - if so, fall back to the (possibly truncated) values
 * in the bottom now playing pane.
 */
function titleAndArtist() {
  var mainContentTableRow = $("tr.selectable").has("a.nowPlaying");
  if (mainContentTableRow.size () > 0) {
    return {
      title: mainContentTableRow.children("td.titleCell").attr("title"),
      artist: mainContentTableRow.children("td.artistCell").attr("title")
    }
  } else {
    var currentSongDetails = $(".currentSongDetails .title");
    return {
      title: currentSongDetails.text(),
      // substring(3) because format is: 'by Artist'
      artist: currentSongDetails.next().text().substring(3)
    }
  }
}

/**
 * Takes raw string, checks that it is in the form "xx:xx", and
 * calculates and returns the number of seconds, otherwise returns
 * -1 indicating failure to parse.
 */
function parseTime (maybeTime) {
  if (typeof(maybeTime) == "string" && maybeTime.indexOf (":") > 0) {
    var timeArr = maybeTime.split(":");
    return parseInt(timeArr[0])*60 + parseInt(timeArr[1]);
  } else {
    return -1;
  }
}

function currentTimeAndTrackDuration () {
  var songStatusTimer = $(".currentSongStatus .timer");
  return {
    currentTime: parseTime(songStatusTimer.find("#currentTime").html()),
    trackDuration: parseTime(songStatusTimer.children().filter(":last").html())
  }
{'fraction_non_alphanumeric': 0.14543937708565072, 'fraction_numerical': 0.005839822024471635, 'mean_word_length': 4.102127659574468, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4275495', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1066, 'n_words': 308}