YouTube.com Video download helper

Adds a button to open a Video download website.

目前为 2022-09-10 提交的版本。查看 最新版本

// ==UserScript==
// @name         YouTube.com Video download helper
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Adds a button to open a Video download website.
// @author       Kvali
// @match        https://www.youtube.com/watch*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    function getRightControls(){
        return document.getElementsByClassName('ytp-right-controls')[0];
    }

    function download(){
    var id = window.location.search.split('v=')[1];
    let hrefDownload ='https://www.y2mate.com/youtube/' + id.split('&t=')[0];
      window.open(hrefDownload, '_blank');
    }

    function createButton(){
        const swb = document.createElement('button');
        swb.classList.add('ytp-button');
        swb.classList.add('downloadBTN');
        swb.innerHTML = `<svg viewBox="-6 -6 36 36" height="100%" width="100%">
<path d="M17 18V19H6V18H17ZM16.5 11.4L15.8 10.7L12 14.4V4H11V14.4L7.2 10.6L6.5 11.3L11.5 16.3L16.5 11.4Z"
fill="#fff">
</path>
</svg>`;
        swb.title = 'Set current playback time to URL (u)';
        swb.onclick = download;
        return swb;
    }

    let panel = getRightControls();
    panel.insertBefore(createButton(), panel.firstChild);
})();