Sleek YouTube Downloader (MP3/MP4)

A simple tool that adds YouTube-style buttons for MP3/MP4 conversion. Lighter than most download scripts.

目前为 2022-01-11 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Sleek YouTube Downloader (MP3/MP4)
  3. // @namespace https://github.com/thisismy-github
  4. // @description A simple tool that adds YouTube-style buttons for MP3/MP4 conversion. Lighter than most download scripts.
  5. // @author thisismy-github
  6. // @match https://www.youtube.com/
  7. // @match https://www.youtube.com/watch*
  8. // @grant none
  9. // @license MIT
  10. // @run-at document-end
  11. // @version 1.0.1
  12. // ==/UserScript==
  13.  
  14.  
  15. const mp3ButtonText = "MP3";
  16. const mp4ButtonText = "MP4";
  17. function mp3() { window.open(`https://yt.clit.repl.co/download/index.html?ytid=${ location.href.split('=')[1] }&format=mp3`); }
  18. function mp4() { window.open(`https://loader.to/en49/?link=${ location.href }&f=7&s=1&e=1&r=loader`); }
  19.  
  20.  
  21. const cssText = `
  22. .download-button {
  23. display: flex;
  24. flex-direction: row;
  25. cursor: pointer;
  26. background-color: var(--yt-spec-10-percent-layer);
  27. color: var(--yt-spec-text-secondary);
  28. border-radius: 2px;
  29. padding: var(--yt-button-padding);
  30. margin: auto var(--ytd-subscribe-button-margin, 4px);
  31. white-space: nowrap;
  32. font-size: var(--ytd-tab-system_-_font-size);
  33. font-weight: var(--ytd-tab-system_-_font-weight);
  34. letter-spacing: var(--ytd-tab-system_-_letter-spacing);
  35. text-transform: var(--ytd-tab-system_-_text-transform);
  36. }
  37. .download-button-text {
  38. --yt-formatted-string-deemphasize_-_display: initial;
  39. --yt-formatted-string-deemphasize-color: var(--yt-spec-text-secondary);
  40. --yt-formatted-string-deemphasize_-_margin-left: 4px;
  41. }
  42. .download-button-container {
  43. display: flex;
  44. flex-direction: row;
  45. cursor: grabbing;
  46. }
  47. `;
  48.  
  49.  
  50. (function() {
  51. 'use strict';
  52. window.onload = () => {
  53. window.addEventListener("yt-navigate-finish", () => {
  54. setTimeout(() => {
  55.  
  56. // apply css
  57. const style = document.createElement("style");
  58. style.type = "text/css";
  59. style.innerHTML = cssText;
  60. document.head.appendChild(style);
  61.  
  62. document.querySelectorAll("#analytics-button:not(.download-panel)").forEach(panel => {
  63. panel.classList.add("download-panel");
  64.  
  65. // mp4 button
  66. const buttonMP4 = document.createElement("div"); // button
  67. buttonMP4.classList.add("download-button");
  68. buttonMP4.addEventListener("click", mp4);
  69. const textMP4 = document.createElement("span"); // text
  70. textMP4.classList.add("download-button-text");
  71. textMP4.innerHTML = mp4ButtonText;
  72. buttonMP4.appendChild(textMP4); // append text to button
  73.  
  74. // mp3 button
  75. const buttonMP3 = document.createElement("div"); // button
  76. buttonMP3.classList.add("download-button");
  77. buttonMP3.addEventListener("click", mp3);
  78. const textMP3 = document.createElement("span"); // text
  79. textMP3.classList.add("download-button-text");
  80. textMP3.innerHTML = mp3ButtonText;
  81. buttonMP3.appendChild(textMP3); // append text to button
  82.  
  83. // outer container (to flex buttons side-by-side)
  84. const container = document.createElement("div");
  85. container.classList.add("download-button-container");
  86. container.appendChild(buttonMP3);
  87. container.appendChild(buttonMP4);
  88. panel.insertBefore(container, panel.firstElementChild);
  89. });
  90. }, 200);
  91. });
  92. };
  93. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址