Created
October 9, 2026 15:00
-
-
Save SalimF/dc7e41dc72c02debc3449ff7f4e12ccc to your computer and use it in GitHub Desktop.
Multi-site Video URL Extractor-2.0.user
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 Multi-site Video URL Extractor | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2.0 | |
| // @description Extract video/embed URLs from both nested iframes and JSON/API responses | |
| // @author You | |
| // @match https://det.animerco.org/* | |
| // @match https://wb.animeluxe.org/* | |
| // @match https://*.animerco.org/* | |
| // @match https://megamax.me/* | |
| // @match https://blkom.com/watch/* | |
| // @grant GM_addStyle | |
| // @grant GM_setClipboard | |
| // @run-at document-start | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // ========================= | |
| // CONFIG | |
| // ========================= | |
| const TARGET_CONTAINER_ID = 'player'; | |
| const WRAPPER_SRC_PATTERN = 'jwplayer'; | |
| const NESTED_SRC_PATTERNS = ['mp4upload','streamtape','doodstream','filelions', | |
| 'voe.sx','voe-network','mixdrop','lulustream', 'mail.ru', | |
| 'krakenfiles','veev','vidhidevip','earnvids', | |
| 'hexload','hexupload','darkibox','megamax', 'bkvideo.online' ]; | |
| const POLL_INTERVAL_MS = 200; | |
| const MAX_POLL_ATTEMPTS = 60; | |
| // STATE | |
| let displayBox = null; | |
| let urlTextEl = null; | |
| let listEl = null; | |
| let observer = null; | |
| let iframeObserver = null; | |
| const foundUrls = new Map(); // url -> meta object | |
| const processedJsonStrings = new Set(); | |
| // UI | |
| function createDisplayBox() { | |
| if (displayBox) return; | |
| displayBox = document.createElement('div'); | |
| displayBox.id = 'extracted-url-box'; | |
| displayBox.style.cssText = [ | |
| 'position:fixed','top:12px','right:12px','z-index:2147483647', | |
| 'background:#0f0f1a','border:2px solid #00d4aa','border-radius:10px','padding:14px','min-width:360px','max-width:540px', | |
| 'max-height:80vh','overflow:auto','font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif', | |
| 'font-size:13px','color:#e0e0ff','box-shadow:0 8px 32px rgba(0,212,170,.25)' | |
| ].join(';'); | |
| displayBox.innerHTML = ` | |
| <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;padding-bottom:8px;border-bottom:1px solid #2a2a4a;"> | |
| <strong style="color:#00d4aa;font-size:14px;">Extracted Video URLs</strong> | |
| <div style="display:flex;gap:6px;"> | |
| <button id="copy-all-btn" style="background:linear-gradient(135deg,#00d4aa,#00aa88);border:none;border-radius:6px;padding:6px 10px;cursor:pointer;font-weight:600;color:#001a14;">Copy all</button> | |
| <button id="refresh-btn" style="background:#2a2a4a;border:1px solid #4a4a6a;border-radius:6px;padding:6px 10px;cursor:pointer;color:#ccc;">Re-scan</button> | |
| <button id="hide-btn" style="background:#3a2a2a;border:1px solid #5a3a3a;border-radius:6px;padding:6px 10px;cursor:pointer;color:#ccc;">Hide</button> | |
| </div> | |
| </div> | |
| <div id="status-text" style="background:#1a1a2e;padding:8px 10px;border-radius:6px;line-height:1.4;color:#a0d4ff;font-size:12px;margin-bottom:10px;">Waiting for player / API response...</div> | |
| <div id="url-list" style="display:flex;flex-direction:column;gap:8px;"></div> | |
| `; | |
| document.documentElement.appendChild(displayBox); | |
| urlTextEl = displayBox.querySelector('#status-text'); | |
| listEl = displayBox.querySelector('#url-list'); | |
| displayBox.querySelector('#copy-all-btn').addEventListener('click', copyAllUrls); | |
| displayBox.querySelector('#refresh-btn').addEventListener('click', manualRescan); | |
| displayBox.querySelector('#hide-btn').addEventListener('click', () => { | |
| displayBox.style.display = 'none'; | |
| }); | |
| } | |
| function updateStatus(text, color = '#a0d4ff') { | |
| createDisplayBox(); | |
| urlTextEl.textContent = text; | |
| urlTextEl.style.color = color; | |
| } | |
| function escapeHtml(s) { | |
| return String(s).replace(/[&<>"']/g, m => ({ | |
| '&':'&', | |
| '<':'<', | |
| '>':'>', | |
| '"':'"', | |
| "'":''' | |
| }[m])); | |
| } | |
| function renderList() { | |
| createDisplayBox(); | |
| if (!foundUrls.size) { | |
| listEl.innerHTML = ''; | |
| return; | |
| } | |
| const items = Array.from(foundUrls.values()); | |
| listEl.innerHTML = items.map((item, idx) => { | |
| const meta = []; | |
| if (item.driver) meta.push(item.driver); | |
| if (item.label) meta.push(item.label); | |
| if (item.resolution) meta.push(item.resolution); | |
| if (item.source) meta.push(item.source); | |
| return ` <div style="background:#1a1a2e;border:1px solid #2f3b55;border-radius:8px;padding:8px;"> | |
| <div style="display:flex;justify-content:space-between;gap:8px;align-items:center;margin-bottom:6px;"> | |
| <div style="font-size:11px;color:#7fdcc9;">${escapeHtml(meta.join(' | ') || ('URL ' + (idx + 1)))}</div> | |
| <button data-url="${escapeHtml(item.url)}" class="copy-one-btn" style="background:#24324a;border:1px solid #3d567d;border-radius:5px;padding:4px 8px;cursor:pointer;color:#d8e6ff;font-size:11px;">Copy</button> | |
| </div> | |
| <div style="word-break:break-all;font-family:monospace;font-size:12px;color:#cfe3ff;">${escapeHtml(item.url)}</div> | |
| </div> | |
| `; | |
| }).join(''); | |
| listEl.querySelectorAll('.copy-one-btn').forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const url = btn.getAttribute('data-url'); | |
| copyText(url); | |
| const old = btn.textContent; | |
| btn.textContent = 'Copied'; | |
| setTimeout(() => btn.textContent = old, 1200); | |
| }); | |
| }); | |
| //updateStatus('');`Found ${items.length} unique URL(s).`, '#00ff99' | |
| } | |
| function copyText(text) { | |
| if (typeof GM_setClipboard === 'function') { | |
| GM_setClipboard(text); | |
| } else if (navigator.clipboard?.writeText) { | |
| navigator.clipboard.writeText(text); | |
| } | |
| } | |
| function copyAllUrls() { | |
| const text = Array.from(foundUrls.values()) | |
| .map(v => { | |
| const left = [v.driver, v.label, v.resolution].filter(Boolean).join(' | '); | |
| return left ? `[${left}] ${v.url}` : v.url; | |
| }) | |
| .join('\n'); | |
| if (!text) { | |
| updateStatus('No URLs found yet.', '#ffaa66'); | |
| return; | |
| } | |
| copyText(text); | |
| updateStatus('All URLs copied.', '#00ff99'); | |
| } | |
| // HELPERS | |
| function normalizeUrl(url) { | |
| if (!url) return ''; | |
| url = String(url).trim().replace(/\s+/g, ''); | |
| if (url.startsWith('//')) url = location.protocol + url; | |
| return url; | |
| } | |
| function addUrl(url, meta = {}) { | |
| url = normalizeUrl(url); | |
| if (!url || url.startsWith('about:')) return false; | |
| if (foundUrls.has(url)) return false; | |
| if (foundUrls.has(url) || ['.js', '.png', 'someText'].some(v => url.includes(v))) { | |
| return false; | |
| } | |
| foundUrls.set(url, { | |
| url, | |
| driver: meta.driver || '', | |
| label: meta.label || '', | |
| resolution: meta.resolution || '', | |
| source: meta.source || '' | |
| }); | |
| console.log('[Extractor] Found URL:', foundUrls.get(url)); | |
| renderList(); | |
| return true; | |
| } | |
| function looksLikeVideoHost(url) { | |
| if (!url) return false; | |
| return NESTED_SRC_PATTERNS.some(p => url.includes(p)); | |
| } | |
| // JSON EXTRACTION | |
| function extractFromStreamsObject(obj, sourceLabel = 'json') { | |
| if (!obj || typeof obj !== 'object') return false; | |
| let added = false; | |
| const data = obj?.props?.streams?.data; | |
| if (Array.isArray(data)) { | |
| data.forEach(entry => { | |
| const label = entry?.label || ''; | |
| const resolution = entry?.resolution || ''; | |
| const mirrors = entry?.mirrors; | |
| if (Array.isArray(mirrors)) { | |
| mirrors.forEach(m => { | |
| if (m?.link) { | |
| added = addUrl(m.link, { | |
| driver: m.driver || '', | |
| label, | |
| resolution, | |
| source: sourceLabel | |
| }) || added; | |
| } | |
| }); | |
| } | |
| }); | |
| } | |
| return added; | |
| } | |
| function deepSearchForLinks(obj, path = '', sourceLabel = 'json-deep') { | |
| let added = false; | |
| if (!obj || typeof obj !== 'object') return false; | |
| if (Array.isArray(obj)) { | |
| obj.forEach((v, i) => { | |
| added = deepSearchForLinks(v, path + '[' + i + ']', sourceLabel) || added; | |
| }); | |
| return added; | |
| } | |
| for (const [key, value] of Object.entries(obj)) { | |
| const p = path ? path + '.' + key : key; | |
| if (typeof value === 'string') { | |
| const n = normalizeUrl(value); | |
| if (/^https?:\/\//i.test(n) || /^\/\//.test(value)) { | |
| if (looksLikeVideoHost(n) || /\/embed|\/e\/|\/v\//i.test(n)) { | |
| added = addUrl(n, { driver: key, source: sourceLabel + ':' + p }) || added; | |
| } | |
| } | |
| } else if (value && typeof value === 'object') { | |
| added = deepSearchForLinks(value, p, sourceLabel) || added; | |
| } | |
| } | |
| return added; | |
| } | |
| function tryParseJsonText(text, sourceLabel = 'json-text') { | |
| if (!text || typeof text !== 'string') return false; | |
| const trimmed = text.trim(); | |
| if (!trimmed) return false; | |
| if (processedJsonStrings.has(trimmed)) return false; | |
| let obj = null; | |
| try { | |
| obj = JSON.parse(trimmed); | |
| } catch (_) { | |
| return false; | |
| } | |
| processedJsonStrings.add(trimmed); | |
| let added = false; | |
| added = extractFromStreamsObject(obj, sourceLabel) || added; | |
| added = deepSearchForLinks(obj, '', sourceLabel) || added; | |
| return added; | |
| } | |
| function scanInlineScriptsForJson() { | |
| document.querySelectorAll('script:not([src])').forEach(scr => { | |
| const txt = scr.textContent || ''; | |
| if (txt.includes('"streams"') || txt.includes('"mirrors"') || txt.includes('"props"')) { | |
| tryParseJsonText(txt, 'inline-script'); | |
| } | |
| }); | |
| } | |
| // FETCH / XHR HOOKS | |
| function hookFetch() { | |
| if (!window.fetch) return; | |
| const origFetch = window.fetch; | |
| window.fetch = async function(...args) { | |
| const res = await origFetch.apply(this, args); | |
| try { | |
| const cloned = res.clone(); | |
| const contentType = cloned.headers.get('content-type') || ''; | |
| if (contentType.includes('application/json') || contentType.includes('text/plain') || contentType.includes('javascript')) { | |
| cloned.text().then(text => { | |
| const ok = tryParseJsonText(text, 'fetch'); | |
| if (ok) updateStatus('URLs extracted from fetch response.', '#00ff99'); | |
| }).catch(() => {}); | |
| } | |
| } catch (_) {} | |
| return res; | |
| }; | |
| } | |
| function hookXHR() { | |
| const origOpen = XMLHttpRequest.prototype.open; | |
| const origSend = XMLHttpRequest.prototype.send; | |
| XMLHttpRequest.prototype.open = function(method, url, ...rest) { | |
| this._extractor_url = url; | |
| return origOpen.call(this, method, url, ...rest); | |
| }; | |
| XMLHttpRequest.prototype.send = function(...args) { | |
| this.addEventListener('readystatechange', function() { | |
| if (this.readyState !== 4) return; | |
| try { | |
| const contentType = this.getResponseHeader('content-type') || ''; | |
| const text = this.responseText; | |
| if (typeof text === 'string' && (contentType.includes('application/json') || text.startsWith('{') || text.startsWith('['))) { | |
| const ok = tryParseJsonText(text, 'xhr'); | |
| if (ok) updateStatus('URLs extracted from XHR response.', '#00ff99'); | |
| } | |
| } catch (_) {} | |
| }); | |
| return origSend.apply(this, args); | |
| }; | |
| } | |
| // OLD IFRAME EXTRACTOR | |
| function extractNestedUrl(wrapperIframe) { | |
| try { | |
| const doc = wrapperIframe.contentDocument || wrapperIframe.contentWindow?.document; | |
| if (!doc) return null; | |
| for (const pattern of NESTED_SRC_PATTERNS) { | |
| const nested = doc.querySelector(`iframe[src*="${pattern}"]`); | |
| if (nested?.src) return normalizeUrl(nested.src); | |
| } | |
| const anyIframe = doc.querySelector('iframe[src]'); | |
| if (anyIframe?.src && !anyIframe.src.startsWith('about:')) { | |
| return normalizeUrl(anyIframe.src); | |
| } | |
| } catch (_) {} | |
| return null; | |
| } | |
| function monitorWrapper(wrapperIframe) { | |
| let attempts = 0; | |
| const tryExtract = () => { | |
| const url = extractNestedUrl(wrapperIframe); | |
| if (url) { | |
| addUrl(url, { source: 'nested-iframe' }); | |
| return true; | |
| } | |
| return false; | |
| }; | |
| if (tryExtract()) return; | |
| const interval = setInterval(() => { | |
| attempts++; | |
| if (tryExtract() || attempts >= MAX_POLL_ATTEMPTS) { | |
| clearInterval(interval); | |
| if (attempts >= MAX_POLL_ATTEMPTS && foundUrls.size === 0) { | |
| updateStatus('No iframe URL found yet. Waiting for API/player...', '#ffaa66'); | |
| } | |
| } | |
| }, POLL_INTERVAL_MS); | |
| wrapperIframe.addEventListener('load', () => { | |
| setTimeout(tryExtract, 250); | |
| }, { once: true }); | |
| } | |
| function scanPlayerContainer() { | |
| const player = document.getElementById(TARGET_CONTAINER_ID); | |
| if (!player) return; | |
| const iframes = player.querySelectorAll('iframe'); | |
| for (const iframe of iframes) { | |
| const src = iframe.src || ''; | |
| if (src.includes(WRAPPER_SRC_PATTERN) || looksLikeVideoHost(src)) { | |
| if (looksLikeVideoHost(src)) { | |
| addUrl(src, { source: 'direct-iframe' }); | |
| } else { | |
| monitorWrapper(iframe); | |
| } | |
| } | |
| } | |
| } | |
| function initObserver() { | |
| // Scan immediately, even if the player is outside #player. | |
| scanPlayerContainer(); | |
| function scanIframe(iframe, sourceLabel = 'mutation-iframe') { | |
| const src = iframe.src || ''; | |
| if (src.includes(WRAPPER_SRC_PATTERN)) { | |
| monitorWrapper(iframe); | |
| } | |
| if (looksLikeVideoHost(src)) { | |
| addUrl(src, { source: sourceLabel }); | |
| } | |
| } | |
| // Detect iframes that already exist. | |
| document.querySelectorAll('iframe[src]').forEach(iframe => { | |
| scanIframe(iframe, 'initial-page-scan'); | |
| }); | |
| // Watch for iframes inserted anywhere in the page. | |
| observer = new MutationObserver(mutations => { | |
| for (const mutation of mutations) { | |
| for (const node of mutation.addedNodes) { | |
| if (node.nodeType !== 1) continue; | |
| if (node.tagName === 'IFRAME') { | |
| scanIframe(node); | |
| } | |
| if (node.querySelectorAll) { | |
| node.querySelectorAll('iframe').forEach(iframe => { | |
| scanIframe(iframe); | |
| }); | |
| } | |
| if (node.tagName === 'SCRIPT' && !node.src) { | |
| tryParseJsonText( | |
| node.textContent || '', | |
| 'dynamic-script' | |
| ); | |
| } | |
| } | |
| } | |
| }); | |
| observer.observe(document.documentElement, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| // Detect src changes, including iframes initially created without src. | |
| iframeObserver = new MutationObserver(mutations => { | |
| for (const mutation of mutations) { | |
| if ( | |
| mutation.type === 'attributes' && | |
| mutation.attributeName === 'src' && | |
| mutation.target.tagName === 'IFRAME' | |
| ) { | |
| scanIframe(mutation.target, 'iframe-src-change'); | |
| } | |
| } | |
| }); | |
| iframeObserver.observe(document.documentElement, { | |
| attributes: true, | |
| attributeFilter: ['src'], | |
| subtree: true | |
| }); | |
| } | |
| // MANUAL RESCAN | |
| function manualRescan() { | |
| updateStatus('Re-scanning page...', '#a0d4ff'); | |
| scanInlineScriptsForJson(); | |
| scanPlayerContainer(); | |
| document.querySelectorAll('iframe[src]').forEach(iframe => { | |
| const src = iframe.src || ''; | |
| if (looksLikeVideoHost(src)) addUrl(src, { source: 'manual-page-scan' }); | |
| }); | |
| document.querySelectorAll('[src],[href]').forEach(el => { | |
| const val = el.getAttribute('src') || el.getAttribute('href') || ''; | |
| if (val && looksLikeVideoHost(val)) { | |
| addUrl(val, { source: 'manual-attr-scan' }); | |
| } | |
| }); | |
| } | |
| // INIT | |
| function init() { | |
| createDisplayBox(); | |
| hookFetch(); | |
| hookXHR(); | |
| if (document.readyState === 'complete' || document.readyState === 'interactive') { | |
| scanInlineScriptsForJson(); | |
| setTimeout(scanPlayerContainer, 700); | |
| setTimeout(initObserver, 1200); | |
| } else { | |
| document.addEventListener('DOMContentLoaded', () => { | |
| scanInlineScriptsForJson(); | |
| setTimeout(scanPlayerContainer, 700); | |
| setTimeout(initObserver, 1200); | |
| }); | |
| } | |
| document.addEventListener('click', () => { | |
| setTimeout(() => { | |
| scanInlineScriptsForJson(); | |
| scanPlayerContainer(); | |
| }, 900); | |
| }, true); | |
| window.addEventListener('load', () => { | |
| setTimeout(() => { | |
| scanInlineScriptsForJson(); | |
| scanPlayerContainer(); | |
| }, 1200); | |
| }); | |
| } | |
| init(); | |
| window.addEventListener('beforeunload', () => { | |
| observer?.disconnect(); | |
| iframeObserver?.disconnect(); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment