בכל מקרה מצרף שוב והפעם בלי ספוילר שלא תהיינה בעיות. אחד מעתיק ואחד שומר כקובץ:
javascript:(async () => { /* Helper function to trigger file download */ const downloadJSON = (data, filename) => { const jsonStr = JSON.stringify(data, null, 2); const blob = new Blob([jsonStr], { type: 'application/json' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = filename; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }; try { if (!window.ajaxify || !window.ajaxify.data.tid) { alert('נראה שאתה לא בעמוד של נושא (topic). יש להפעיל את הסימניה מעמוד נושא תקין.'); return; } const tid = window.ajaxify.data.tid; const safeTitle = (window.ajaxify.data.title || 'topic').replace(/[^a-z0-9]/gi, '_').toLowerCase(); const filename = `topic_${tid}_${safeTitle}.json`; alert(`מתחיל איסוף פוסטים מנושא מספר ${tid}. בסיום התהליך, תתחיל הורדת קובץ בשם:\n${filename}`); /* Steps 1 & 2: Fetch all posts from all pages */ const pagination = await fetch(`/api/topic/pagination/${tid}`).then(res => res.json()); const pageCount = pagination.pagination.pageCount; const allPagePromises = Array.from({ length: pageCount }, (_, i) => i + 1) .map(page => fetch(`/api/topic/${tid}?page=${page}`) .then(res => res.json()) .then(data => data.posts) ); /* Step 3: Wait for all promises and flatten the result */ const allPages = await Promise.all(allPagePromises); const posts = allPages.flat(); /* Step 4: Download the collected data as a JSON file */ downloadJSON(posts, filename); } catch (error) { console.error(%27אירעה שגיאה במהלך איסוף הפוסטים:%27, error); alert(%27אירעה שגיאה. בדוק את חלון המפתחים (F12) לפרטים נוספים.%27); }})();
javascript:(async () => { try { if (!window.ajaxify || !window.ajaxify.data.tid) { alert('נראה שאתה לא בעמוד של נושא (topic). יש להפעיל את הסימניה מעמוד נושא תקין.'); return; } const tid = window.ajaxify.data.tid; alert(`מתחיל איסוף פוסטים מנושא מספר ${tid}. בסיום, התוכן יועתק אוטומטית ללוח.`); /* Steps 1 & 2: Fetch all posts from all pages */ const pagination = await fetch(`/api/topic/pagination/${tid}`).then(res => res.json()); const pageCount = pagination.pagination.pageCount; const allPagePromises = Array.from({ length: pageCount }, (_, i) => i + 1) .map(page => fetch(`/api/topic/${tid}?page=${page}`) .then(res => res.json()) .then(data => data.posts) ); /* Step 3: Wait for all promises and flatten the result */ const allPages = await Promise.all(allPagePromises); const posts = allPages.flat(); /* Step 4: Convert to JSON string and copy to clipboard */ const jsonStr = JSON.stringify(posts, null, 2); await navigator.clipboard.writeText(jsonStr); alert(`איסוף הושלם! ${posts.length} פוסטים הועתקו ללוח כטקסט JSON.\nכעת ניתן להדביק (Ctrl+V) אותם בכל מקום.`); } catch (error) { console.error(%27אירעה שגיאה:%27, error); alert(%27אירעה שגיאה. ייתכן שההעתקה ללוח נכשלה. בדוק את חלון המפתחים (F12) לפרטים.%27); }})();




