YouTube Downloader

Author: Maker - MH

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         YouTube Downloader
// @version      1.3
// @match        https://www.youtube.com/*
// @match      https://www.wheelofnames.fun/*
// @grant        GM_setClipboard
// @description  Author: Maker - MH
// @namespace https://greasyfork.org/users/1115232
// ==/UserScript==
 
document.addEventListener('keydown', function(event) {
  if (event.ctrlKey && event.shiftKey && event.key === 'Y') {
    event.preventDefault();
    GM_setClipboard(window.location.href);
    window.open('https://x2download.app/' + window.location.pathname);
  }
});
 
(function() {
  'use strict';
 
  function pasteTextAndClickButton() {
    var searchBox = document.getElementById('s_input');
    var button = document.querySelector('#search-form button');
 
    setTimeout(function() {
      navigator.clipboard.readText().then(function(pastedText) {
        searchBox.value = pastedText;
        button.click();
 
        setTimeout(function() {
          var downloadLink = document.getElementById('asuccess');
          if (downloadLink) {
            downloadLink.addEventListener('click', function() {
              setTimeout(function() {
                window.close();
              }, 8000);
            });
          }
        }, 2000);
      }).catch(function(error) {
        console.error('Error reading text from clipboard:', error);
      });
    }, 1000);
  }
 
  window.addEventListener('load', function() {
    pasteTextAndClickButton();
  });
})();