SptfyCpyforF

For personal use

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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