Youtube Downloader

Adds a download button (That actually looks good) that redirects to yt1s.com.

  1. // ==UserScript==
  2. // @name Youtube Downloader
  3. // @namespace http://qweren.neocities.org/
  4. // @icon https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/YouTube_full-color_icon_%282017%29.svg/1024px-YouTube_full-color_icon_%282017%29.svg.png
  5. // @version Release
  6. // @description Adds a download button (That actually looks good) that redirects to yt1s.com.
  7. // @author qweren
  8. // @match *://www.youtube.com/watch?v=*
  9. // @grant none
  10. // @run-at document-body
  11. // @license CC-BY-NC-SA
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. // Function to append the button and tooltip
  16. function appendButtonAndTooltip() {
  17. const menu = document.getElementById("top-level-buttons-computed");
  18.  
  19. // Remove existing download button
  20. const existingDownloadButton = document.querySelector('.style-scope.ytd-download-button-renderer');
  21. if (existingDownloadButton) existingDownloadButton.remove();
  22.  
  23. const containerDiv = document.createElement('div');
  24. containerDiv.className = 'tooltip-container';
  25.  
  26. const newButton = document.createElement('button');
  27. newButton.style.marginLeft = "8px";
  28. newButton.innerHTML = `<svg height='24' viewBox='0 0 24 24' width='24' focusable='false'><path fill='white' d='M17 18v1H6v-1h11zm-.5-6.6-.7-.7-3.8 3.7V4h-1v10.4l-3.8-3.8-.7.7 5 5 5-4.9z'></path></svg>`;
  29. newButton.setAttribute("id", "download-button");
  30.  
  31. const tooltip = document.createElement('tp-yt-paper-tooltip');
  32. tooltip.setAttribute('fit-to-visible-bounds', '');
  33. tooltip.setAttribute('offset', '8');
  34. tooltip.style = 'inset: 44px auto auto 187.258px;';
  35. tooltip.textContent = 'Download';
  36. tooltip.classList.remove('hidden');
  37. containerDiv.appendChild(tooltip);
  38.  
  39. const currentLink = encodeURIComponent(window.location.href);
  40. const redirectURL = `https://yt1s.com/en/youtube-to-mp4?q=${currentLink}`;
  41.  
  42. newButton.addEventListener('click', () => window.open(redirectURL, '_blank'));
  43. newButton.className = 'yt-spec-button-shape-next yt-spec-button-shape-next--tonal yt-spec-button-shape-next--mono yt-spec-button-shape-next--size-m yt-spec-button-shape-next--icon-leading ';
  44.  
  45. containerDiv.appendChild(newButton);
  46. menu.appendChild(containerDiv);
  47. }
  48.  
  49. // Append the button and tooltip when the page loads
  50. setTimeout(appendButtonAndTooltip, 5000);
  51.  
  52. setInterval(function () {
  53. if(document.getElementById("container")){
  54. if(!document.getElementById("download-button")){
  55. appendButtonAndTooltip();
  56. }
  57. }
  58. }, 6000);
  59. })();