Apple music - Copy playlist info

Copy playlist info for export

  1. // ==UserScript==
  2. // @name Apple music - Copy playlist info
  3. // @description Copy playlist info for export
  4. // @namespace cobr123
  5. // @version 1.0
  6. // @license MIT
  7. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
  8. // @grant GM.setClipboard
  9. // @grant GM_setClipboard
  10. // @include https://music.apple.com/*
  11. // ==/UserScript==
  12.  
  13. "use strict";
  14.  
  15. (function () {
  16. function copyPL() {
  17. let svPlayList = '';
  18. $('div[class="tracklist-item__text we-selectable-item__link-text"]').each(function() {
  19. let row = $(this);
  20. let svTrackName = $('div:nth-child(1) > a > div > span', row).text().replace("\n","");
  21. let svArtistName = $('div:nth-child(2) > a', row).text().replace("\n","");
  22. let svTrackInfo = svTrackName + ' - ' + svArtistName;
  23. console.log(svTrackInfo);
  24. svPlayList += svTrackInfo + '\n';
  25. });
  26. GM_setClipboard(svPlayList);
  27. alert('Copied:\n' + svPlayList);
  28. }
  29. let bindEvents = function () {
  30. $("div.product-hero-desc--side-bar").after('<button id="copy_playlist_to_clipboard" class="product-controls__button link">Copy playlist to clipboard</button>');
  31. $('#copy_playlist_to_clipboard').click(function(){
  32. copyPL();
  33. });
  34. };
  35. window.setTimeout(bindEvents, 1000);
  36.  
  37. })();