chosic.com - export playlist

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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