SptfyCpyforF

For personal use

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.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

Advertisement:

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!)

Advertisement:

// ==UserScript==
// @name         SptfyCpyforF
// @namespace    https://greasyfork.org/ja/users/1582093-mxmoor
// @version      0.8
// @description  For personal use
// @author       SY
// @match        https://open.spotify.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    window.setTimeout(initScript, 2000);

    function initScript(){
        // 1. 対象の要素を取得
        const targetElement = document.querySelector('.AYUEkKOEqksuTXmh');

        // 2. ボタン要素を作成
        if (targetElement) {

            // 2. ボタン要素を作成
            const newButton = document.createElement('button');
            newButton.textContent = '曲情報をコピー';
            newButton.className = 'my-custom-button'; // 任意のクラス名を追加

            // 3. 必要に応じてイベントリスナーを追加
            newButton.addEventListener('click', () => {
                if(document.getElementsByClassName('NNafsIKjQaOOVJsH')[0].innerText.slice(0, 1) == "曲"){
                    const parts = document.getElementsByClassName('NNafsIKjQaOOVJsH')[0].innerText.split("\n");
                    const tab = String.fromCharCode(9);
                    navigator.clipboard.writeText(parts[1] + tab + parts[2] + tab + parts[4] + tab + tab + parts[8]);
                    newButton.textContent = 'コピーしました';
                    setTimeout(() => {
                        newButton.textContent = '曲情報をコピー';
                    }, 2000);
                } else {
                    alert('曲情報がありません');
                }
            });

            // 4. 対象要素にボタンを追加
            targetElement.appendChild(newButton);
        } else {
            console.warn('指定されたクラスの要素が見つかりませんでした。');
        }
        console.log("All resources finished loading!");
    }
})();