跳到主内容
paste
bin
.ca
type · paste · share
⌘
K
系列
bin 系列
pastebin.ca
中心
Share text and code with expiry and privacy controls.
imagebin.ca
Upload and share images with direct links.
filebin.ca
Drop a file and get a shareable link.
notebin.ca
Write Markdown notes with durable links.
turl.ca
Short, reputation-checked links.
attn.ca
Notifications and alerts for your services.
voicebin.ca
Record and share short voice clips.
dnsbin.ca
Inspect DNS and debug records.
登录
?
账户
更多
▾
文档
← 返回文本
›
编辑 / 分支
无标题文本
#26RxGqzq9a
public / public
新版本
匿名
已创建 5 days ago
过期于 2 days
15.0 KB
语法:
text
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
新版本
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
标题(可选)
文件名
语法
text
text
bash
c
cpp
css
diff
dockerfile
go
html
ini
java
javascript
json
kotlin
lua
makefile
markdown
nginx
php
python
ruby
rust
shellscript
sql
swift
toml
typescript
xml
yaml
可见性
公开动态
访问
public
过期
7 天
10 分钟
1 小时
1 天
7 天
30 天
90 天
自定义…
自定义过期
变更备注
(可选)
任何人都能在公开动态中找到此文本。选择“未列出”即可仅通过链接分享。
创建新版本
取消
粘贴或输入…
// ==UserScript== // @name OSHO World · Cross-Page Collector // @namespace https://oshoworld.com/ // @version 1.0 // @description Manually paginate, collect MP3 URLs across pages, download all at once. // @author BROK // @match https://oshoworld.com/* // @match https://www.oshoworld.com/* // @grant GM_download // @run-at document-idle // ==/UserScript== (function () { 'use strict'; const CFG = { storageKey: 'osho_collector_v1', batchDelayMin: 1200, batchDelayMax: 2800, maxBatch: 100 }; const sleep = ms => new Promise(r => setTimeout(r, ms)); const esc = t => { const d = document.createElement('div'); d.appendChild(document.createTextNode(String(t))); return d.innerHTML; }; function filenameFromUrl(url) { try { return decodeURIComponent(new URL(url, location.href).pathname.split('/').pop() || 'audio.mp3'); } catch (e) { return 'audio.mp3'; } } function cleanName(f) { return f.replace(/\.mp3$/i, '').replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim(); } // ============ STATE ============ function load() { try { return JSON.parse(sessionStorage.getItem(CFG.storageKey) || 'null') || { urls: [], page: 1 }; } catch (e) { return { urls: [], page: 1 }; } } function save(s) { sessionStorage.setItem(CFG.storageKey, JSON.stringify(s)); } let store = load(); let currentPageMp3 = []; let downloading = false; let stopFlag = false; // ============ SCAN ============ function scan() { const found = new Set(); document.querySelectorAll('a[href]').forEach(a => { if (/\.mp3(\?|$)/i.test(a.href)) found.add(a.href); }); document.querySelectorAll('audio[src], audio source[src]').forEach(el => { const s = el.src || el.getAttribute('src'); if (s && /\.mp3(\?|$)/i.test(s)) found.add(new URL(s, location.href).href); }); const html = document.documentElement.innerHTML; const re = /https?:\/\/[^\s"'<>()\\]+?\.mp3(?:\?[^\s"'<>()\\]*)?/gi; let m; while ((m = re.exec(html)) !== null) found.add(m[0].replace(/\\\//g, '/')); const relRe = /["']([^"']*?\/wp-content\/uploads\/[^"']*?\.mp3)["']/gi; while ((m = relRe.exec(html)) !== null) { try { found.add(new URL(m[1], location.href).href); } catch (e) {} } currentPageMp3 = Array.from(found).sort().map(url => ({ url, name: filenameFromUrl(url) })); return currentPageMp3; } // ============ DOWNLOAD ============ function downloadOne(item) { return new Promise(resolve => { if (typeof GM_download === 'function') { GM_download({ url: item.url, name: item.name, onload: () => resolve(true), onerror: () => { anchor(item); resolve(false); }, ontimeout: () => { anchor(item); resolve(false); } }); } else { anchor(item); resolve(true); } }); } function anchor(item) { const a = document.createElement('a'); a.href = item.url; a.download = item.name; a.style.display = 'none'; document.body.appendChild(a); a.click(); setTimeout(() => a.remove(), 100); } // ============ UI ============ let panel, statusEl, collCountEl, pageCountEl, listEl; function buildPanel() { panel = document.createElement('div'); panel.id = 'osho-col'; panel.innerHTML = ` <style> #osho-col{position:fixed;top:16px;right:16px;width:480px;max-width:calc(100vw - 32px);z-index:999999;font-family:'SF Mono','Fira Code',Consolas,monospace;font-size:12px;color:#e0d8c8;background:#12100c;border:1px solid #2a2418;border-radius:8px;box-shadow:0 8px 32px rgba(0,0,0,.7);overflow:hidden} #osho-col .ch{display:flex;justify-content:space-between;align-items:center;padding:10px 14px;background:linear-gradient(180deg,#1a1510,#12100c);border-bottom:1px solid #2a2418;cursor:move;user-select:none} #osho-col .ct{font-size:12px;font-weight:700;letter-spacing:.08em;color:#c9a961} #osho-col .cc{background:transparent;border:none;color:#6a5e48;font-size:16px;cursor:pointer;padding:0 4px} #osho-col .cb{padding:12px 14px;max-height:75vh;overflow-y:auto} #osho-col.col-collapsed .cb{display:none} #osho-col button{background:#8b6f3a;color:#0a0806;border:none;border-radius:4px;padding:6px 12px;font:inherit;font-size:11px;font-weight:700;cursor:pointer;letter-spacing:.04em;transition:.15s;white-space:nowrap} #osho-col button:hover:not(:disabled){background:#c9a961;box-shadow:0 0 10px rgba(201,169,97,.4)} #osho-col button:disabled{opacity:.4;cursor:not-allowed} #osho-col button.ol{background:transparent;border:1px solid #2a2418;color:#e0d8c8} #osho-col button.ol:hover:not(:disabled){border-color:#c9a961;background:#1a1510;box-shadow:none} #osho-col button.gr{background:#2e6b3e;color:#fff} #osho-col button.gr:hover:not(:disabled){background:#3d8a52} #osho-col button.dg{background:#7a3030;color:#fff} #osho-col button.dg:hover:not(:disabled){background:#c94e4e} #osho-col .row{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px} #osho-col .st{font-size:11px;color:#6a5e48;margin-bottom:8px;min-height:16px;display:flex;align-items:center;gap:6px} #osho-col .st.loading::before{content:'';width:10px;height:10px;border:2px solid #2a2418;border-top-color:#c9a961;border-radius:50%;animation:csp .7s linear infinite;flex-shrink:0} @keyframes csp{to{transform:rotate(360deg)}} #osho-col .st.success{color:#6fbf73} #osho-col .st.error{color:#c94e4e} #osho-col .bg{display:inline-block;background:#2a2418;color:#c9a961;font-size:10px;font-weight:700;padding:2px 8px;border-radius:10px;margin-left:6px} #osho-col .info{margin:6px 0;font-size:11px;color:#8a7e68} #osho-col .info b{color:#c9a961} #osho-col .ls{max-height:300px;overflow-y:auto;background:#080604;border:1px solid #2a2418;border-radius:4px} #osho-col .ls::-webkit-scrollbar{width:5px} #osho-col .ls::-webkit-scrollbar-thumb{background:#2a2418;border-radius:3px} #osho-col .it{display:flex;align-items:center;gap:8px;padding:6px 10px;border-bottom:1px solid #14110a;font-size:11px} #osho-col .it:last-child{border-bottom:none} #osho-col .ix{color:#4a4238;font-size:10px;min-width:22px;text-align:right} #osho-col .nm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} #osho-col .it button{padding:3px 8px;font-size:10px;font-weight:600} #osho-col .em{padding:20px;text-align:center;color:#6a5e48;font-size:11px} </style> <div class="ch" id="col-drag"> <span class="ct">OSHO · CROSS-PAGE COLLECTOR</span> <button class="cc" id="col-collapse">−</button> </div> <div class="cb"> <div class="st" id="col-status">Ready</div> <div class="row"> <button id="col-add" class="gr">➕ Add This Page</button> <button id="col-scan" class="ol">🔄 Scan</button> </div> <div class="info"> Page: <b id="col-page">1</b> · Collected: <b id="col-total">0</b> MP3 </div> <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;"> <span style="font-size:10px;color:#6a5e48;text-transform:uppercase;letter-spacing:.08em;">This page</span> <span class="bg" id="col-page-count">0</span> </div> <div class="ls" id="col-list"> <div class="em">Click Scan to see MP3s on this page.</div> </div> <div class="row" style="margin-top:10px;"> <button id="col-download" class="dg">⬇ Download All Collected</button> <button id="col-copy" class="ol">📋 Copy All</button> <button id="col-clear" class="ol">🗑 Clear</button> </div> <div class="info" style="margin-top:8px;"> <b>Workflow:</b> 1) Scan → 2) Add This Page → 3) click "Next" in the site → 4) repeat → 5) Download All. </div> </div> `; document.body.appendChild(panel); statusEl = panel.querySelector('#col-status'); listEl = panel.querySelector('#col-list'); collCountEl = panel.querySelector('#col-total'); pageCountEl = panel.querySelector('#col-page-count'); panel.querySelector('#col-collapse').addEventListener('click', () => { panel.classList.toggle('col-collapsed'); panel.querySelector('#col-collapse').textContent = panel.classList.contains('col-collapsed') ? '+' : '−'; }); makeDraggable(panel, panel.querySelector('#col-drag')); panel.querySelector('#col-scan').addEventListener('click', () => { scan(); renderList(); setStatus(`Scanned · ${currentPageMp3.length} MP3 on this page`, currentPageMp3.length ? 'success' : 'error'); }); panel.querySelector('#col-add').addEventListener('click', () => { scan(); renderList(); if (currentPageMp3.length === 0) { setStatus('No MP3 on this page to add', 'error'); return; } let added = 0; for (const item of currentPageMp3) { if (!store.urls.find(u => u.url === item.url)) { store.urls.push({ url: item.url, name: item.name }); added++; } } save(store); updateTotals(); setStatus(`Added ${added} new MP3 · total ${store.urls.length}`, 'success'); }); panel.querySelector('#col-download').addEventListener('click', async () => { if (downloading) return; if (store.urls.length === 0) { setStatus('Nothing collected yet', 'error'); return; } const n = Math.min(store.urls.length, CFG.maxBatch); if (!confirm(`Download ${n} collected MP3?\n\nTotal in collection: ${store.urls.length}\nDownloading first ${n} only.`)) return; downloading = true; stopFlag = false; updateButtons(); let ok = 0; for (let i = 0; i < n; i++) { if (stopFlag) break; const item = store.urls[i]; setStatus(`⬇ ${i + 1}/${n} · ${cleanName(item.name)}`, 'loading'); await downloadOne(item); ok++; if (i < n - 1) await sleep(CFG.batchDelayMin + Math.random() * (CFG.batchDelayMax - CFG.batchDelayMin)); } downloading = false; updateButtons(); setStatus(`Done · ${ok}/${n} triggered`, 'success'); }); panel.querySelector('#col-copy').addEventListener('click', () => { if (store.urls.length === 0) { setStatus('Nothing to copy', 'error'); return; } const txt = store.urls.map(u => u.url).join('\n'); navigator.clipboard.writeText(txt).then(() => setStatus(`Copied ${store.urls.length} URLs`, 'success')); }); panel.querySelector('#col-clear').addEventListener('click', () => { if (!confirm('Clear all collected URLs?')) return; store = { urls: [], page: 1 }; save(store); updateTotals(); setStatus('Cleared', 'success'); }); listEl.addEventListener('click', e => { const btn = e.target.closest('button[data-act]'); if (!btn) return; const i = parseInt(btn.dataset.idx); const item = currentPageMp3[i]; if (!item) return; if (btn.dataset.act === 'dl') downloadOne(item).then(() => setStatus(`⬇ ${cleanName(item.name)}`, 'success')); else if (btn.dataset.act === 'copy') navigator.clipboard.writeText(item.url).then(() => { const o = btn.textContent; btn.textContent = '✓'; setTimeout(() => btn.textContent = o, 1000); }); }); updateTotals(); } function renderList() { pageCountEl.textContent = currentPageMp3.length; if (currentPageMp3.length === 0) { listEl.innerHTML = '<div class="em">No MP3 on this page.</div>'; return; } const frag = document.createDocumentFragment(); currentPageMp3.forEach((item, i) => { const div = document.createElement('div'); div.className = 'it'; div.innerHTML = ` <span class="ix">${String(i + 1).padStart(2, '0')}</span> <span class="nm" title="${esc(item.url)}">${esc(cleanName(item.name))}</span> <button data-act="copy" data-idx="${i}">Copy</button> <button data-act="dl" data-idx="${i}">DL</button> `; frag.appendChild(div); }); listEl.innerHTML = ''; listEl.appendChild(frag); } function updateTotals() { collCountEl.textContent = store.urls.length; document.getElementById('col-page').textContent = store.page || 1; } function setStatus(msg, type = '') { statusEl.textContent = msg; statusEl.className = 'st ' + type; } function updateButtons() { document.getElementById('col-download').disabled = downloading; document.getElementById('col-add').disabled = downloading; } function makeDraggable(el, handle) { let sx = 0, sy = 0, ox = 0, oy = 0, d = false; handle.addEventListener('mousedown', e => { if (e.target.tagName === 'BUTTON') return; d = true; sx = e.clientX; sy = e.clientY; const r = el.getBoundingClientRect(); ox = r.left; oy = r.top; e.preventDefault(); }); document.addEventListener('mousemove', e => { if (!d) return; el.style.left = (ox + e.clientX - sx) + 'px'; el.style.top = (oy + e.clientY - sy) + 'px'; el.style.right = 'auto'; }); document.addEventListener('mouseup', () => { d = false; }); } function init() { buildPanel(); setTimeout(() => { scan(); renderList(); setStatus(currentPageMp3.length ? `Auto-scanned · ${currentPageMp3.length} MP3` : 'No MP3 on this page. Click Scan.', currentPageMp3.length ? 'success' : ''); }, 800); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();