YouSnatch - YouTube Video Downloader

Adds a download button next to YouTube's volume control

当前为 2025-05-03 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         YouSnatch - YouTube Video Downloader
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a download button next to YouTube's volume control
// @author       You
// @match        https://www.youtube.com/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Function to create the download button
    function createDownloadButton() {
        const button = document.createElement('button');
        button.textContent = 'YouSnatch';
        button.style.backgroundColor = '#FF5C00';  // Color
        button.style.color = 'white';
        button.style.border = 'none';
        button.style.padding = '5px 10px';
        button.style.fontSize = '14px';
        button.style.cursor = 'pointer';
        button.style.marginLeft = '10px';
        button.style.borderRadius = '4px';
        button.setAttribute('title', 'Download Video');
        button.setAttribute('aria-label', 'Download Video');

        // Add functionality for video download (stub)
        button.addEventListener('click', () => {
            alert("Downloading the highest quality video...");
            // Video download logic will go here
        });

        return button;
    }

    // Function to insert the button next to the volume control
    function insertButtonNextToVolume() {
        const volumePanel = document.querySelector('.ytp-volume-panel');

        if (volumePanel) {
            const button = createDownloadButton();
            if (!document.querySelector('.yousnatch-btn')) {  // Prevent multiple button creations
                button.classList.add('yousnatch-btn');  // Add a class for reference
                volumePanel.appendChild(button);  // Append the button next to the volume
            }
        } else {
            // If volume panel is not found, wait a little and try again
            setTimeout(insertButtonNextToVolume, 1000);
        }
    }

    // Insert button after the page is fully loaded
    window.addEventListener('load', () => {
        insertButtonNextToVolume();
    });
})();