0

I use this script to generate download links :

javascript: (function () {
  function callback() {
    (function ($) {
      var jQuery = $;
      window.files = new Array;
      window.i = 0;
      grabFiles();
      window.i = 0;
      $("#track_table div.dl_link").each(function (index) {
        $(this).show();
        $(this).html('<a href="' + window.files[i] + '">download</a>');
        window.i = window.i + 1;
      });

      function grabFiles() {
        $(TralbumData.trackinfo).each(function (index) {
          window.files[i] = this['file']['mp3-128'];
          window.i = window.i + 1;
        });
      }
    })(jQuery.noConflict(true))
  }
  var s = document.createElement("script");
  s.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js";
  if (s.addEventListener) {
    s.addEventListener("load", callback, false)
  } else if (s.readyState) {
    s.onreadystatechange = callback
  }
  document.body.appendChild(s);
})()

I discovered a page where it doesn't work : A Bird Story «OST»

It can get the download link of the first track, but it don't wan't to show it.

Someone have an idea ?

David Thomas
  • 249,100
  • 51
  • 377
  • 410
Gimlao
  • 101
  • 3

1 Answers1

0

Just found the solution. x)

There was something missing in the grabFiles function :

function grabFiles() {
  $(TralbumData.trackinfo).each(function (index) {
    if (this['file'] != null) {
      window.files[i] = this['file']['mp3-128'];
    }
    window.i = window.i + 1;
  });
}

Now, it will not try to read the non-existing mp3-128 value when file is null. ^^;

Gimlao
  • 101
  • 3