YouSnatch - YouTube Video Downloader

Adds a download button next to YouTube's volume control

  1. // ==UserScript==
  2. // @name YouSnatch - YouTube Video Downloader
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Adds a download button next to YouTube's volume control
  6. // @author You
  7. // @match https://www.youtube.com/*
  8. // @grant GM_addStyle
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to create the download button
  15. function createDownloadButton() {
  16. const button = document.createElement('button');
  17. button.textContent = 'YouSnatch';
  18. button.style.backgroundColor = '#FF5C00'; // Color
  19. button.style.color = 'white';
  20. button.style.border = 'none';
  21. button.style.padding = '5px 10px';
  22. button.style.fontSize = '14px';
  23. button.style.cursor = 'pointer';
  24. button.style.marginLeft = '10px';
  25. button.style.borderRadius = '4px';
  26. button.setAttribute('title', 'Download Video');
  27. button.setAttribute('aria-label', 'Download Video');
  28.  
  29. // Add functionality for video download (stub)
  30. button.addEventListener('click', () => {
  31. alert("Downloading the highest quality video...");
  32. // Video download logic will go here
  33. });
  34.  
  35. return button;
  36. }
  37.  
  38. // Function to insert the button next to the volume control
  39. function insertButtonNextToVolume() {
  40. const volumePanel = document.querySelector('.ytp-volume-panel');
  41.  
  42. if (volumePanel) {
  43. const button = createDownloadButton();
  44. if (!document.querySelector('.yousnatch-btn')) { // Prevent multiple button creations
  45. button.classList.add('yousnatch-btn'); // Add a class for reference
  46. volumePanel.appendChild(button); // Append the button next to the volume
  47. }
  48. } else {
  49. // If volume panel is not found, wait a little and try again
  50. setTimeout(insertButtonNextToVolume, 1000);
  51. }
  52. }
  53.  
  54. // Insert button after the page is fully loaded
  55. window.addEventListener('load', () => {
  56. insertButtonNextToVolume();
  57. });
  58. })();