您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a download button next to YouTube's volume control
- // ==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();
- });
- })();