BitChute | Video Download Button

Adds a "Download" button to every BitChute video page

当前为 2018-04-16 提交的版本,查看 最新版本

// ==UserScript==
// @name            BitChute | Video Download Button
// @namespace       de.sidneys.greasemonkey
// @homepage        https://gist.githubusercontent.com/sidneys/b4783b0450e07e12942aa22b3a11bc00/raw/
// @version         1.2.0
// @description     Adds a "Download" button to every BitChute video page
// @author          sidneys
// @icon            https://www.bitchute.com/static/images/android-icon-192x192.png
// @include         *://*bitchute.com/video/*
// @require         https://gf.qytechs.cn/scripts/38888-greasemonkey-color-log/code/Greasemonkey%20%7C%20Color%20Log.js
// @require         https://gf.qytechs.cn/scripts/38889-greasemonkey-waitforkeyelements-2018/code/Greasemonkey%20%7C%20waitForKeyElements%202018.js
// @run-at          document-end
// ==/UserScript==

/**
 * @default
 * @constant
 */
DEBUG = false;


/**
 * Render download button
 * @param {String} target - Target URL
 */
let renderDownloadButton = (target) => {
    console.debug('renderDownloadButton');

    /**
     * URL
     * @type {URL}
     */
    const targetURL = new URL(target);

    /**
     * Href
     * @type {String}
     */
    const targetHref = targetURL.href;

    /**
     * Filename
     * @type {String}
     */
    const targetFilename = targetURL.pathname.split('/').pop();

    // Create element
    const element = document.createElement('li');
    element.innerHTML = `
        <a href="${targetHref}" download="${targetFilename}">
            Download Video (${targetFilename})
        </a>
    `;

    // Append element
    const parentElement = document.querySelector('.video-info-bar ul.info-ul');
    parentElement.appendChild(element);

    /**
     * Filename
     * @type {String}
     */
    console.info('Video Download URL:', targetHref);
};


/**
 * Init
 */
let init = () => {
    console.debug('init');


    // Watch feed items
    waitForKeyElements('source', (element) => {
        renderDownloadButton(element.src);
    });
};


/**
 * @listens window:Event#load
 */
window.addEventListener('load', () => {
    console.debug('window#load');

    init();
});

QingJ © 2025

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