Twitch Clip Downloader

adds a download link to twitch clips

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();
    });
})();