SptfyCpyforF

For personal use

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Advertisement:

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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!");
    }
})();