function getPlaylistData() const videos = []; const videoElements = document.querySelectorAll("ytd-playlist-video-renderer"); videoElements.forEach(el => const title = el.querySelector("#video-title")?.innerText; const url = el.querySelector("#video-title")?.href; if (title && url) videos.push( title, url );
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => if (request.action === "getPlaylist") sendResponse( videos: getPlaylistData() );
const express = require("express"); const exec = require("child_process"); const app = express(); app.get("/download", (req, res) => const videoUrl = req.query.url; exec( yt-dlp -g $videoUrl , (error, stdout) => if (error) return res.status(500).send("Error"); res.json( downloadUrl: stdout.trim() ); ); );
); Your extension will call http://localhost:3000/download?url=VIDEO_URL
function getPlaylistData() const videos = []; const videoElements = document.querySelectorAll("ytd-playlist-video-renderer"); videoElements.forEach(el => const title = el.querySelector("#video-title")?.innerText; const url = el.querySelector("#video-title")?.href; if (title && url) videos.push( title, url );
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => if (request.action === "getPlaylist") sendResponse( videos: getPlaylistData() );
const express = require("express"); const exec = require("child_process"); const app = express(); app.get("/download", (req, res) => const videoUrl = req.query.url; exec( yt-dlp -g $videoUrl , (error, stdout) => if (error) return res.status(500).send("Error"); res.json( downloadUrl: stdout.trim() ); ); );
); Your extension will call http://localhost:3000/download?url=VIDEO_URL