Greasy Fork is available in English.
adds a download link to twitch clips
< Feedback on Twitch Clip Downloader
var fail = 0; This is never incremented.
Here is some revised code:
(function() { 'use strict'; var link; var fail = 0; const log = (str) => console.log(`[CDL] ${str}`); function geturl() { link = document.querySelector(".video-player__container > video:nth-child(1)")?.getAttribute("src"); if (link === null || link === undefined) { log("waiting"); if (fail < 5) { fail++; setTimeout(geturl, 500); } } else { log("found clip link") link = link.replace(/\?.*/g, ""); log(link); document.querySelector("div.clips-watch > div.tw-animation > div.tw-c-background-base")?.insertAdjacentHTML('afterend', `<div><a class="tw-align-items-center tw-align-middle tw-border-bottom-left-radius-medium tw-border-bottom-right-radius-medium tw-border-top-left-radius-medium tw-border-top-right-radius-medium tw-core-button tw-core-button--primary tw-inline-flex tw-justify-content-center tw-overflow-hidden tw-relative" href="${link}" download>Download Clip</a></div>`) } } if (document.readyState === "complete") { geturl(); } else if (document.readyState === "interactive") { // DOM ready! Images, frames, and other subresources are still downloading. geturl(); } else { // Loading still in progress. // To wait for it to complete, add "DOMContentLoaded" or "load" listeners. window.addEventListener("DOMContentLoaded", () => { // DOM ready! Images, frames, and other subresources are still downloading. geturl(); }); } })();
Sign in to post a reply.
var fail = 0; This is never incremented.
Here is some revised code: