mylist-list

guroshi

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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==
// @name         mylist-list
// @namespace    twitter.com/neon_uriel
// @version      2025-02-03
// @description  guroshi
// @author       neon
// @match        https://www.nicovideo.jp/watch/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=nicovideo.jp
// @run-at      document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 監視対象のノード (body 全体を監視)
    const targetNode = document.body;
    const url = new URL(window.location.href);
    const smNumber = url.pathname.substring(url.pathname.lastIndexOf('/') + 1);

    // MutationObserver のコールバック関数
    const observerCallback = function(mutationsList, observer) {
        for (let mutation of mutationsList) {
            if (mutation.type === 'childList') {
                let menu = document.querySelector('#menu\\:\\:rk\\:\\:content');
                if (menu && !document.getElementById('custom-button')) {
                    addButton(menu);
                    observer.disconnect(); // 1回追加したら監視を終了
                }
            }
        }
    };

    // ボタンを追加する関数
    function addButton(target) {
        let button = document.createElement('button');
        button.id = 'custom-button';
        button.innerText = 'マイリスト一覧';
        button.style.margin = '10px';
        button.style.padding = '5px 10px';
        button.style.cursor = 'pointer';


        // ボタンのクリックイベント
        button.addEventListener('click', function() {
            console.log('ボタンがクリックされました');
            window.open("https://www.nicovideo.jp/openlist/" + smNumber, "_blank");
        });

        // 指定の要素にボタンを追加
        target.appendChild(button);
        console.log('ボタンを追加しました');
    }

    // MutationObserver のオプション (子ノードの変更を監視)
    const observerOptions = { childList: true, subtree: true };

    // MutationObserver を作成
    const observer = new MutationObserver(observerCallback);

    // 監視を開始
    observer.observe(targetNode, observerOptions);
})();