YouTube Download Button Mobile

Download video or mp3 from YouTube Mobile.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        YouTube Download Button Mobile
// @description	Download video or mp3 from YouTube Mobile.
// @version     1.5
// @author      look997
// @match       https://m.youtube.com/watch*
// @homepageURL https://greasyfork.org/pl/users/4353-look997
// @namespace   https://greasyfork.org/pl/users/4353-look997
// @grant       none
// @run-at      document-end
// @icon        https://www.google.com/s2/favicons?domain=youtube.com
// @icon64      https://www.google.com/s2/favicons?domain=youtube.com
// ==/UserScript==

function addButton () {
	const el = document.createElement("ytm-button-renderer");
	el.classList.add("slim_video_action_bar_renderer_button");
	const targetEl = document.querySelector("ytm-slim-video-action-bar-renderer > .slim-video-action-bar-actions");
  
	if (!targetEl) { return false; }
	targetEl.append(el);
	
console.log("bla-in-2");
	
	const buttonEl = document.createElement("button");
	buttonEl.textContent = "Download";
	buttonEl.title = "Download video or mp3";
	buttonEl.classList.add("yt-spec-button-shape-next");
	buttonEl.classList.add("yt-spec-button-shape-next--tonal");
	buttonEl.classList.add("yt-spec-button-shape-next--mono");
	buttonEl.classList.add("yt-spec-button-shape-next--size-m");
	buttonEl.classList.add("yt-spec-button-shape-next--icon-leading");
	
	function download(){
		const id = new URLSearchParams (window.location.search).get("v");
		const hrefDownload ='https://en.loader.to/4/?link=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D'+ id + '3&f=6&s=1&e=1&r=ddownr'
		window.open(hrefDownload, '_blank');
	}
	buttonEl.addEventListener("click", download);
	
	el.replaceChildren(buttonEl);
	
}

(function() {
	
	'use strict';
	
	window.addEventListener("yt-navigate-finish", addButton, true);
	setTimeout(addButton,1000);
	
})();