// ==UserScript== // @name Youtube download button - yt1s.com (revised SuchtiOnTour Edit) // @name:de Youtube download button - yt1s.com (revised SuchtiOnTour Edit) // @namespace Violentmonkey Scripts // @match https://www.youtube.com/watch // @match https://*.youtube.com/* // @grant GM_addStyle // @run-at document-start // @version 1.0 // @author SuchtiOnTour // @license MIT // @description Adds a youtube download Button // @description:de Fügt einen YouTube-Download-Button hinzu // @downloadURL none // ==/UserScript== (function() { const API = "https://yt1s.com/en/youtube-to-mp3?q="; const BUTTON_ID = "dwnldBtn"; const TARGET_BUTTON = "#analytics-button"; const buttonStyle = ` #${BUTTON_ID} { background-color: #0F0F0F; color: #FFFFFF; border: 1px solid #3F3F3F; border-color: rgba(255,255,255,0.2); margin: 0px 4px; border-radius: 18px; width: 94.56px; height: 36px; line-height: 37px; text-align: center; font-style: normal; font-size: 14px; font-family: Roboto, Noto, sans-serif; font-weight: 500; text-decoration: none; } #${BUTTON_ID}:hover { background-color: #3F3F3F; color: #ffffff; border-color: #3F3F3F; } `; GM_addStyle(buttonStyle); function waitForElement(selector) { return new Promise(resolve => { if (document.querySelector(selector)) { return resolve(document.querySelector(selector)); } const observer = new MutationObserver(mutations => { if (document.querySelector(selector)) { resolve(document.querySelector(selector)); observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true }); }); } function addButton() { waitForElement(TARGET_BUTTON).then((btn) => { btn.innerHTML += `Download`; }); } function updateButton() { waitForElement(`#${BUTTON_ID}`).then((btn) => { btn.href = API + encodeURIComponent(window.location.href); }); } window.onload = addButton; window.addEventListener("yt-navigate-start", updateButton, true); })();