(async function () {
const delay = ms => new Promise(res => setTimeout(res, ms));
// 1) Auto-scroll to load lazy items
let lastHeight = -1;
while (document.body.scrollHeight !== lastHeight) {
lastHeight = document.body.scrollHeight;
window.scrollTo(0, document.body.scrollHeight);
await delay(1200);
}
// 2) Collect links
const links = [];
const cards = document.querySelectorAll("div.tw-aspect-video");
for (const card of cards) {
try {
const img = card.querySelector("img");
if (!img || !img.src) continue;
const parts = img.src.split("/");
const randomToken = parts[parts.length - 2] || "";
const videoId = (parts[parts.length - 1] || "").split(".")[0] || "";
// 3) Try to find the displayed filename by searching ancestors for a span with .txt/.mp4
let filename = null;
let node = card;
for (let i = 0; i < 8 && node; i++) {
const spans = node.querySelectorAll("span");
for (const s of spans) {
const t = s.textContent.trim();
if (!t) continue;
// Prefer span texts that end with common extensions (txt/mp4/etc)
if (/\.(txt|mp4|mov|mkv|avi)$/i.test(t)) {
filename = t;
break;
}
// Sometimes UI shows names without extension — try short heuristic (has underscore + digits)
if (/^\d+[_\-\w ]+\.[a-z]{1,5}$/i.test(t)) {
filename = t;
break;
}
}
if (filename) break;
node = node.parentElement;
}
// fallback: try a few common selectors near card
if (!filename) {
const alt = card.parentElement?.querySelector("span.tw-text-ellipsis, span.tw-overflow-hidden, span.tw-text-textTitle span");
if (alt) filename = alt.textContent.trim();
}
// final fallback -> videoId
if (!filename) filename = videoId || "video";
// Ensure file ends with .mp4 (if UI shows "name.txt", we keep it and add .mp4 -> name.txt.mp4)
if (!/\.(mp4|mov|mkv|avi)$/i.test(filename)) {
filename = filename + ".mp4";
}
// Build final base URL and percent-encoded query param
const baseUrl = `https://resource2.heygen.ai/video/transcode/${videoId}/${randomToken}/1920x1080.mp4`;
const q = encodeURIComponent(`attachment; filename*=UTF-8''${filename};`);
const final = `${baseUrl}?response-content-disposition=${q}`;
links.push(final);
} catch (err) {
console.error("card error", err);
}
}
console.log("✅ Found", links.length, "links");
console.log(links.join("\n"));
// copy to clipboard for quick paste
try {
await navigator.clipboard.writeText(links.join("\n"));
console.log("✅ Links copied to clipboard");
} catch (e) {
console.warn("Could not copy to clipboard:", e);
}
return links;
})();
## run above code in console to get all the download links... run below code in python script to download one by one. replace the URLs
0 comments:
Post a Comment