Created
March 29, 2026 20:29
-
-
Save Astolfo2001/a81a6766f56d43a93adb8539d3479203 to your computer and use it in GitHub Desktop.
failed attempt to make the Sora Video URL Scraper UserScript work properly with Firefox and its forks; again, generated using Grok
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Sora Video URLs Exporter - LibreWolf Fixed (Save As + Reliable Clipboard) | |
| // @namespace https://x.ai/grok | |
| // @version 0.8 | |
| // @description Scroll → collect video URLs → Save As dialog + reliable clipboard fallback for LibreWolf | |
| // @author Grok (clanker-aware) | |
| // @match *://sora.com/* | |
| // @match *://*.sora.com/* | |
| // @match *://sora.chatgpt.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| let collected = new Set(); | |
| let running = false; | |
| function copyToClipboard(text) { | |
| // Modern Clipboard API (preferred but often blocked in LibreWolf) | |
| if (navigator.clipboard && navigator.clipboard.writeText) { | |
| navigator.clipboard.writeText(text).then(() => { | |
| console.log("%c[Sora Exporter] Copied via modern Clipboard API", "color:#00ff9d"); | |
| }).catch(() => { | |
| fallbackCopy(text); | |
| }); | |
| return; | |
| } | |
| // Old-school fallback (more reliable on hardened LibreWolf) | |
| fallbackCopy(text); | |
| } | |
| function fallbackCopy(text) { | |
| const textarea = document.createElement('textarea'); | |
| textarea.value = text; | |
| textarea.style.position = 'fixed'; | |
| textarea.style.left = '-999999px'; | |
| textarea.style.top = '-999999px'; | |
| document.body.appendChild(textarea); | |
| textarea.focus(); | |
| textarea.select(); | |
| try { | |
| const successful = document.execCommand('copy'); | |
| if (successful) { | |
| console.log("%c[Sora Exporter] Copied via execCommand fallback", "color:#00ff9d"); | |
| } else { | |
| console.warn("execCommand copy failed."); | |
| } | |
| } catch (err) { | |
| console.warn("Clipboard fallback also failed:", err); | |
| } | |
| document.body.removeChild(textarea); | |
| } | |
| async function scrollAndExport() { | |
| if (running) return; | |
| running = true; | |
| console.log("%c[Sora Exporter] Starting scroll (LibreWolf mode)", "color:#00ff9d; font-weight:bold"); | |
| let lastHeight = 0; | |
| let stuck = 0; | |
| const maxStuck = 12; | |
| while (stuck < maxStuck) { | |
| window.scrollBy(0, window.innerHeight * 0.8); | |
| await new Promise(r => setTimeout(r, 1400)); | |
| document.querySelectorAll('video, source').forEach(el => { | |
| const url = (el.src || el.currentSrc || '').trim(); | |
| if (url.includes('videos.openai.com')) { | |
| collected.add(url); | |
| } | |
| }); | |
| console.log(`[Sora Exporter] Videos collected: ${collected.size}`); | |
| const current = document.body.scrollHeight; | |
| if (current === lastHeight) stuck++; | |
| else stuck = 0; | |
| lastHeight = current; | |
| } | |
| await new Promise(r => setTimeout(r, 2000)); | |
| if (collected.size === 0) { | |
| alert("No video URLs found."); | |
| running = false; | |
| return; | |
| } | |
| const textContent = Array.from(collected).join('\n'); | |
| // 1. Try to copy to clipboard (with fallback) | |
| copyToClipboard(textContent); | |
| // 2. Trigger Save As dialog (this already works for you) | |
| const blob = new Blob([textContent], { type: 'text/plain' }); | |
| const blobUrl = URL.createObjectURL(blob); | |
| const link = document.createElement('a'); | |
| link.href = blobUrl; | |
| link.download = ''; // empty = full Save As dialog | |
| link.style.display = 'none'; | |
| document.body.appendChild(link); | |
| link.click(); | |
| setTimeout(() => { | |
| URL.revokeObjectURL(blobUrl); | |
| document.body.removeChild(link); | |
| }, 1000); | |
| alert(`✅ Done! ${collected.size} video URLs collected.\n\n` + | |
| `• File saved to your Downloads folder (or wherever you chose)\n` + | |
| `• Plain list also copied to clipboard (use Ctrl+V in any text editor)\n\n` + | |
| `If clipboard didn't paste, just open the downloaded .txt file — it's the same list.`); | |
| console.log("%c[Sora Exporter] Export complete. Save As worked + clipboard attempted.", "color:#00ff9d"); | |
| running = false; | |
| } | |
| function addButton() { | |
| const btn = document.createElement('button'); | |
| btn.textContent = '📥 Export Sora Video URLs (LibreWolf Fixed)'; | |
| btn.style.position = 'fixed'; | |
| btn.style.bottom = '30px'; | |
| btn.style.right = '30px'; | |
| btn.style.zIndex = '99999'; | |
| btn.style.padding = '14px 24px'; | |
| btn.style.background = '#00ff9d'; | |
| btn.style.color = '#000'; | |
| btn.style.border = 'none'; | |
| btn.style.borderRadius = '8px'; | |
| btn.style.cursor = 'pointer'; | |
| btn.style.fontWeight = 'bold'; | |
| btn.style.fontSize = '15px'; | |
| btn.onclick = scrollAndExport; | |
| document.body.appendChild(btn); | |
| } | |
| if (typeof GM_registerMenuCommand !== 'undefined') { | |
| GM_registerMenuCommand('Export Sora Videos (LibreWolf Fixed)', scrollAndExport); | |
| } | |
| if (document.readyState === 'loading') { | |
| document.addEventListener('DOMContentLoaded', addButton); | |
| } else { | |
| addButton(); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment