YTModManager

A manager for mods for youtube.com

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         YTModManager
// @namespace	 YTModManager
// @version      1.0 Initial Release
// @author       FlyingGorilla124
// @license      MIT
// @run-at       document-start
// @match        *://*.youtube.com/*
// @match        *://m.youtube.com/*
// @match        *://youtu.be/*
// @grant        none
// @description  A manager for mods for youtube.com
// ==/UserScript==

/*
  MIT License

  Copyright (c) 2026 FlyingGorilla124

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
*/

(function() {
    'use strict';

    window.nexusRegistry = window.nexusRegistry || [];
    const YT_BLUE = '#3ea6ff';
    const BG_DARK = '#0f0f0f';
    const CARD_BG = '#1a1a1a';
    const BORDER_COLOR = '#333';

    const Nexus = {
        mods: {},
        activeTab: 'mods',
        isOpen: false,

        init() {
            setInterval(() => this.scanRegistry(), 1000);
            if (document.readyState === 'loading') {
                document.addEventListener('DOMContentLoaded', () => this.setupUI());
            } else {
                this.setupUI();
            }
        },

        scanRegistry() {
            if (window.nexusRegistry.length > 0) {
                let added = false;
                while(window.nexusRegistry.length > 0) {
                    const mod = window.nexusRegistry.shift();
                    if (!this.mods[mod.id]) {
                        this.mods[mod.id] = mod;
                        added = true;
                    }
                }
                if (added) this.updateTabs();
            }
        },

        updateTabs() {
            const tabbar = document.getElementById('nexus-dynamic-area');
            if (!tabbar) return;
            tabbar.innerHTML = ''; 
            
            Object.values(this.mods).forEach(mod => {
                if (mod.hasUI && mod.enabled) {
                    const tab = document.createElement('div');
                    tab.className = 'nexus-tab';
                    tab.dataset.tab = mod.id;
                    tab.textContent = mod.name;
                    tab.onclick = () => this.switchTab(mod.id);
                    tabbar.appendChild(tab);
                }
            });

            if (this.activeTab !== 'mods' && this.activeTab !== 'settings') {
                if (!this.mods[this.activeTab] || !this.mods[this.activeTab].enabled) {
                    this.switchTab('mods');
                }
            }
            this.syncActiveTabStyle();
        },

        setupUI() {
            this.injectStyles();
            this.createModal();
            this.startObserver();
        },

        injectStyles() {
            if (document.getElementById('nexus-styles')) return;
            const style = document.createElement('style');
            style.id = 'nexus-styles';
            style.textContent = `
                #nexus-modal { 
                    position: fixed; inset: 0; display: none; 
                    background: rgba(0,0,0,0.4); 
                    backdrop-filter: blur(2px); 
                    z-index: 999999; font-family: "Roboto", sans-serif; 
                }
                .nexus-container { 
                    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); 
                    width: 760px; height: 580px; background: ${BG_DARK}; 
                    border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; 
                    border: 1px solid ${BORDER_COLOR};
                    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
                }
                .nexus-tabbar { 
                    display: flex; background: #000; 
                    border-bottom: 1px solid ${BORDER_COLOR}; 
                    align-items: stretch; padding: 0;
                }
                #nexus-dynamic-area { display: flex; align-items: stretch; }
                .nexus-spacer { flex: 1; pointer-events: none; }
                
                .nexus-tab { 
                    display: flex; align-items: center;
                    padding: 0 20px; cursor: pointer; color: #aaa; 
                    font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
                    text-transform: uppercase; transition: 0.15s ease; 
                    border-left: 1px solid transparent;
                    border-right: 1px solid transparent;
                    height: 44px; 
                    margin-bottom: -1px;
                }
                .nexus-tab:hover { color: #fff; background: rgba(255,255,255,0.05); }
                
                .nexus-tab.active { 
                    color: ${YT_BLUE} !important; 
                    background: ${BG_DARK};
                    border-left: 1px solid ${BORDER_COLOR};
                    border-right: 1px solid ${BORDER_COLOR};
                    border-bottom: 1px solid ${BG_DARK};
                    position: relative;
                    z-index: 2;
                }
                
                .nexus-tab.system-tab { font-size: 16px; border-left: 1px solid #222; margin-bottom: 0; }
                .nexus-tab.system-tab.active { border-left: 1px solid ${BORDER_COLOR}; border-right: none; }

                .nexus-content { 
                    flex: 1; padding: 25px; overflow-y: auto; color: #efefef;
                    background: ${BG_DARK};
                }
                
                .nexus-exit-hint {
                    position: absolute; bottom: -30px; left: 0; right: 0;
                    text-align: center; color: rgba(255,255,255,0.5); 
                    font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
                    pointer-events: none;
                }

                .nexus-mod-card { 
                    display: flex; justify-content: space-between; align-items: center; 
                    background: ${CARD_BG}; padding: 14px 20px; border-radius: 10px; 
                    margin-bottom: 12px; border: 1px solid #2a2a2a;
                }

                .n-switch { position: relative; width: 40px; height: 22px; cursor: pointer; }
                .n-switch input { opacity: 0; width: 0; height: 0; }
                .n-slider { position: absolute; inset: 0; background: #333; border-radius: 20px; transition: .3s; }
                .n-slider:before { 
                    position: absolute; content: ""; height: 16px; width: 16px; 
                    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s; 
                }
                input:checked + .n-slider { background: ${YT_BLUE}; }
                input:checked + .n-slider:before { transform: translateX(18px); }

                #nexus-trigger { 
                    background: transparent; border: none; cursor: pointer; 
                    font-size: 18px; margin-right: 15px; color: #fff; 
                    transition: transform 0.3s ease; opacity: 0.7;
                    display: block !important;
                }
                #nexus-trigger:hover { transform: rotate(45deg); opacity: 1; }
                
                .nexus-content::-webkit-scrollbar { width: 6px; }
                .nexus-content::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }
            `;
            document.head.appendChild(style);
        },

        createModal() {
            if (document.getElementById('nexus-modal')) return;
            const modal = document.createElement('div');
            modal.id = 'nexus-modal';
            modal.innerHTML = `
                <div class="nexus-container">
                    <div class="nexus-tabbar">
                        <div class="nexus-tab active" data-tab="mods">Extensions</div>
                        <div id="nexus-dynamic-area"></div>
                        <div class="nexus-spacer"></div>
                        <div class="nexus-tab system-tab" data-tab="settings">⚙️</div>
                    </div>
                    <div class="nexus-content" id="nexus-view"></div>
                    <div class="nexus-exit-hint">Click anywhere outside to close</div>
                </div>
            `;
            modal.addEventListener('click', (e) => { if(e.target === modal) this.toggle(false); });
            document.body.appendChild(modal);
            modal.querySelectorAll('.nexus-tab[data-tab]').forEach(t => t.onclick = () => this.switchTab(t.dataset.tab));
        },

        switchTab(id) {
            this.activeTab = id;
            this.syncActiveTabStyle();
            this.renderContent();
        },

        syncActiveTabStyle() {
            document.querySelectorAll('.nexus-tab').forEach(t => {
                t.classList.toggle('active', t.dataset.tab === this.activeTab);
            });
        },

        toggle(state) {
            this.isOpen = state;
            const m = document.getElementById('nexus-modal');
            if (m) m.style.display = state ? 'block' : 'none';
            if (state) this.renderContent();
        },

        renderContent() {
            const view = document.getElementById('nexus-view');
            if (!view) return;
            view.innerHTML = '';
            
            if (this.activeTab === 'mods') {
                Object.values(this.mods).forEach(mod => {
                    const card = document.createElement('div');
                    card.className = 'nexus-mod-card';
                    card.innerHTML = `<span>${mod.name}</span><label class="n-switch"><input type="checkbox" ${mod.enabled ? 'checked' : ''}><span class="n-slider"></span></label>`;
                    card.querySelector('input').onchange = (e) => {
                        mod.toggle(e.target.checked);
                        this.updateTabs();
                    };
                    view.appendChild(card);
                });
            } else if (this.activeTab === 'settings') {
                view.innerHTML = `
                    <div style="text-align:center; padding-top:40px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
                        <h2 style="color:${YT_BLUE}; margin-bottom:5px; font-weight:400; font-size: 24px;">YTModManager</h2>
                        <p style="color:#888; font-size:13px; margin-bottom:25px;">Version 1.0 Initial Release</p>
                        
                        <a href="https://greasyfork.org/en/scripts?set=594516" target="_blank" style="color:${YT_BLUE}; text-decoration: none; font-size: 14px; margin-bottom: 50px; border: 1px solid ${BORDER_COLOR}; padding: 10px 20px; border-radius: 5px; transition: 0.2s;">
                            Browse More Mods
                        </a>

                        <div style="margin-top: auto; padding-bottom: 20px; color: #555; font-size: 11px; letter-spacing: 0.5px;">
                            © 2026 FlyingGorilla124. All rights reserved.
                        </div>
                    </div>`;
                
                // Add hover effect for the button via JS since we are injecting HTML
                const linkBtn = view.querySelector('a');
                linkBtn.onmouseover = () => { linkBtn.style.background = 'rgba(255,255,255,0.05)'; };
                linkBtn.onmouseout = () => { linkBtn.style.background = 'transparent'; };
            } else {
                const mod = this.mods[this.activeTab];
                if (mod && mod.renderUI) mod.renderUI(view);
            }
        },

        startObserver() {
            const addBtn = () => {
                const mast = document.querySelector('#end.ytd-masthead');
                if (mast && !document.getElementById('nexus-trigger')) {
                    const btn = document.createElement('button');
                    btn.id = 'nexus-trigger'; btn.innerHTML = '⚙️';
                    btn.onclick = (e) => { e.preventDefault(); e.stopPropagation(); this.toggle(true); };
                    mast.insertBefore(btn, mast.firstChild);
                }
            };
            addBtn();
            new MutationObserver(addBtn).observe(document.documentElement, { childList: true, subtree: true });
        }
    };

    Nexus.init();
})();

(function() {
    'use strict';
    const NEXUS_KEY = "83719246";
    window.nexusKey = NEXUS_KEY;
    window.nexusRegistry = window.nexusRegistry || [];
    console.log("[Nexus] Manager initialized with Global Key.");
})();