Twitch Clip Downloader

adds a download link to twitch clips

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Twitch Clip Downloader
// @namespace    cdl
// @version      0.2
// @description  adds a download link to twitch clips
// @author       cc114
// @match        http*://clips.twitch.tv/*
// @exclude      http*://clips.twitch.tv/create
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var link;
    var fail = 0;
    function geturl() {
        console.log('[CDL] searching');
        link = document.querySelector(".video-ref > video").getAttribute("src");
        if (link == null || link == undefined || link == "") {
            console.log('[CDL] waiting');
            if (fail < 5) {
                fail++;
                setTimeout(geturl, 500);
            }
        } else {
            console.log('[CDL] found link: ' + link);
            var div = document.createElement ('div');
            div.innerHTML = '<a href="' + link + '">Download</a>';
            var button = document.querySelectorAll('[data-test-selector="clips-watch-full-button"]')[0];
            button.insertAdjacentElement("afterend",div)
        }
    }
    window.addEventListener('load', () => {
        geturl();
    });
})();