chosic.com - export playlist

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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"));
});