Spotify Web - Copy playlist info

Copy playlist info for export

目前为 2019-12-06 提交的版本。查看 最新版本

// ==UserScript==
// @name          Spotify Web - Copy playlist info
// @description   Copy playlist info for export
// @namespace     cobr123
// @version       2.3
// @license       MIT
// @require       https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
// @grant         GM.setClipboard
// @grant         GM_setClipboard
// @include       https://open.spotify.com/*
// ==/UserScript==
 

"use strict";

(function () {
  
  function copyPL() {
    let svPlayList = '';
    $('ol.tracklist div[class="tracklist-col name"] > div').each(function() {
      let row = $(this);
      let svTrackName = $('div:nth-child(1)', row).text();
      let svArtistName = $('div:nth-child(2) > span.TrackListRow__artists', row).text();
      let svTrackInfo = svTrackName + ' - ' + svArtistName;
      console.log(svTrackInfo);
      svPlayList += svTrackInfo + '\n';
    });
    GM_setClipboard(svPlayList);
    alert('Copied:\n' + svPlayList);
  }
  function copyPLwithTime() {
    let svPlayList = '';
    $('ol.tracklist div[class="tracklist-col name"] > div').each(function() {
      let row = $(this);
      let svTrackName = $('div:nth-child(1)', row).text();
      let svArtistName = $('div:nth-child(2) > span.TrackListRow__artists', row).text();
      let svTrackTime = $('div:nth-child(4)', row.parent().parent()).text();
      let svTrackInfo = svTrackTime + ' ' + svTrackName + ' - ' + svArtistName;
      console.log(svTrackInfo);
      svPlayList += svTrackInfo + '\n';
    });
    GM_setClipboard(svPlayList);
    alert('Copied:\n' + svPlayList);
  }
  
  let bindEvents = function () {
    $("div.TrackListHeader__button").append('<button id="copy_playlist_to_clipboard" class="btn btn-green false">Copy playlist to clipboard</button>');
    $('#copy_playlist_to_clipboard').click(function(){
      copyPL();
    });
    $("div.TrackListHeader__button").append('<button id="copy_playlist_to_clipboard_with_time" class="btn btn-green false">Copy playlist to clipboard with time</button>');
    $('#copy_playlist_to_clipboard_with_time').click(function(){
      copyPLwithTime();
    });
  };
  
  window.setTimeout(bindEvents, 1000);

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址