// ==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.1
// @author SuchtiOnTour
// @license MIT
// @description This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:pt-BR This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ar This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:bg This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:cs This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:da This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:de This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:el This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:eo This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:es This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:fi This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:fr This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:fr-CA This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:he This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:hu This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:id This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:it This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ja This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ko This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:nb This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:nl This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:pl This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ro This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ru This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:sk This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:sr This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:sv This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:th This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:tr This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:uk This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ug This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:vi This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:zh-CN This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:zh-TW This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// ==/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 += `<a href="${API + encodeURIComponent(window.location.href)}" target="_blank" id="${BUTTON_ID}">Download</a>`;
});
}
function updateButton() {
waitForElement(`#${BUTTON_ID}`).then((btn) => {
btn.href = API + encodeURIComponent(window.location.href);
});
}
window.onload = addButton;
window.addEventListener("yt-navigate-start", updateButton, true);
})();