| 1 | (() => { |
| 2 | const S = window.__INITIAL_STATE__; |
| 3 | let list = []; |
| 4 | |
| 5 | // 1) 番剧/影视播放页 (bilibili.com/bangumi/play/...) |
| 6 | if (S?.epList?.length) { |
| 7 | list = S.epList.map(e => ({ |
| 8 | title: e.longTitle || e.title || '', |
| 9 | url: e.shareUrl || `https://www.bilibili.com/bangumi/play/ep${e.epId}` |
| 10 | })); |
| 11 | } |
| 12 | // 2) 普通视频页 |
| 13 | else if (S?.videoData) { |
| 14 | const vd = S.videoData, season = vd.ugc_season; |
| 15 | if (season?.sections?.some(s => s.episodes?.length)) { |
| 16 | // 合集 |
| 17 | season.sections.forEach(s => s.episodes.forEach(ep => |
| 18 | list.push({ title: ep.title || ep.arc?.title || '', |
| 19 | url: `https://www.bilibili.com/video/${ep.bvid}?p=${ep.page?.page || 1}` }))); |
| 20 | } else if (vd.pages?.length) { |
| 21 | // 分P |
| 22 | vd.pages.forEach(p => list.push({ title: p.part, |
| 23 | url: `https://www.bilibili.com/video/${vd.bvid}?p=${p.page}` })); |
| 24 | } else { |
| 25 | list.push({ title: vd.title, url: location.href.split('?')[0] }); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | if (!list.length) return console.warn('未识别到播放列表(不是B站播放页?)'); |
| 30 | console.log(`共 ${list.length} 条`); |
| 31 | console.table(list); |
| 32 | console.log(list.map(x => x.url).join('\n')); // 纯链接 |
| 33 | return list; // 也可拿返回值 |
| 34 | })(); |
给you-get用,在浏览器的console里使用
Revision bf9413dedd9b9db1b4a6c43ca4d482637685d9ad