bcrawlink

Provides links to the raw media files for previews on bandcamp to get around preview listen limits. Also allows you to easily download the previews. >:)

目前为 2016-09-05 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name bcrawlink
  3. // @description Provides links to the raw media files for previews on bandcamp to get around preview listen limits. Also allows you to easily download the previews. >:)
  4. // @license MIT License
  5. // @namespace com.bandcamp.benburrill.evil
  6. // @include *
  7. // @version 2
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // BTW, we run this on all sites because some bandcamp pages are not actually on bandcamp.org
  12.  
  13. $(document).ready(function () {
  14. window.TralbumData && TralbumData.trackinfo.forEach(function (track, index) {
  15. // I've only seen the mp3 type, but if there happen to be more, we want to
  16. // make links for all of them.
  17. track.file && Object.keys(track.file).forEach(function (media_type) {
  18. var cls = "raw-link-" + media_type;
  19. var base = "(tr,div)[rel=\"tracknum=" + (index + 1) + "\"]";
  20. var pref_child = "td.title-col";
  21.  
  22. // If possible, use the child pref_child instead of base.
  23. if ($(base).has(pref_child).length) base += ">" + pref_child;
  24.  
  25. $(base + ":not(:has(a." + cls + "))").each(function () {
  26. $(this).append("<a class=\"" + cls + "\" href=\"" + track.file[media_type] + "\" target=\"_blank\">\n " + media_type + "\n </a>");
  27. });
  28. });
  29. });
  30. });