chosic.com - export playlist

Allows exporting playlist from chosic.com to clipboard without loggin in.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @grant          none
// @version        0.0.3
// @author         eye-wave
// @icon           https://raw.githubusercontent.com/eye-wave/greasy-fork/main/packages/chosic-export-spotify/assets/icon.svg
// @license        GPL-3.0+
// @name           chosic.com - export playlist 
// @namespace      Spotify tools
// @match          https://www.chosic.com/*
// @description    Allows exporting playlist from chosic.com to clipboard without loggin in.
// ==/UserScript==
// ../../utils/src/index.ts
function $(query) {
  return document.querySelectorAll(query);
}
function $s(query) {
  return document.querySelector(query);
}
function copyToClipboard(data) {
  try {
    const text = typeof data === "string" ? data : JSON.stringify(data);
    navigator.clipboard.writeText(text);
  } catch {
    const textarea = document.createElement("textarea");
    textarea.value = typeof data === "string" ? data : JSON.stringify(data);
    document.body.appendChild(textarea);
    textarea.select();
    document.execCommand("copy");
    document.body.removeChild(textarea);
  }
}

// src/main.ts
var btn = $s(".save-playlist>button");
btn && (btn.onclick = () => {
  const list = Array.from($(".fa-spotify"));
  const items = list.reduce((acc, item) => {
    const id = item.getAttribute("data-song-id");
    if (id)
      acc.push(id);
    return acc;
  }, []);
  copyToClipboard(items.join("\n"));
});