This commit is contained in:
Marek
2026-04-05 20:43:35 +02:00
parent f8de245e45
commit f269271c6e
16 changed files with 237 additions and 32 deletions

View File

@@ -40,13 +40,16 @@ function collectVideos(elements) {
let pendingVideos = [];
let sendTimer = null;
function queueVideos(videos) {
async function queueVideos(videos) {
pendingVideos.push(...videos);
if (!sendTimer) {
sendTimer = setTimeout(() => {
sendTimer = setTimeout(async () => {
if (pendingVideos.length > 0) {
console.log(`[YT-Erfasser] ${pendingVideos.length} Videos senden`);
browser.runtime.sendMessage(pendingVideos);
const stored = await browser.storage.local.get("profileId");
const profileId = stored.profileId || null;
const batch = pendingVideos.map((v) => ({ ...v, profile_id: profileId }));
console.log(`[YT-Erfasser] ${batch.length} Videos senden (Profil: ${profileId})`);
browser.runtime.sendMessage(batch);
}
pendingVideos = [];
sendTimer = null;