用户:RedDragon/Test2:修订间差异
来自Rizline中文维基
更多操作
小 |
小 |
||
| 第39行: | 第39行: | ||
.then(r => r.text()) | .then(r => r.text()) | ||
.then(text => { | .then(text => { | ||
console.log(' | console.log('原始响应长度:', text.length) | ||
const | |||
if ( | const parser = new DOMParser() | ||
const doc = parser.parseFromString(text, 'text/html') | |||
const preElement = doc.querySelector('pre') | |||
if (preElement) { | |||
try { | try { | ||
const data = JSON.parse( | const jsonText = preElement.textContent | ||
console.log('找到JSON数据:', jsonText.substring(0, 200)) | |||
const data = JSON.parse(jsonText) | |||
const pages = data.query.pages | const pages = data.query.pages | ||
const pageId = Object.keys(pages)[0] | const pageId = Object.keys(pages)[0] | ||
| 第57行: | 第63行: | ||
} | } | ||
} else { | } else { | ||
console.error(' | console.error('未找到pre元素,尝试其他方法') | ||
useMockData() | const jsonMatch = text.match(/\{"batchcomplete".*?\}(?=\s*<\/pre>)/s) | ||
if (jsonMatch) { | |||
try { | |||
const data = JSON.parse(jsonMatch[0]) | |||
const pages = data.query.pages | |||
const pageId = Object.keys(pages)[0] | |||
const wikitext = pages[pageId].revisions[0]['*'] | |||
const songs = parseSongsFromWikitext(wikitext) | |||
songs.length > 0 | |||
? loadSongColors(songs[Math.floor(Math.random() * songs.length)]) | |||
: useMockData() | |||
} catch (e) { | |||
console.error('JSON解析失败:', e) | |||
useMockData() | |||
} | |||
} else { | |||
console.error('无法提取JSON数据') | |||
useMockData() | |||
} | |||
} | } | ||
}) | }) | ||
| 第95行: | 第120行: | ||
.then(r => r.text()) | .then(r => r.text()) | ||
.then(text => { | .then(text => { | ||
const | const parser = new DOMParser() | ||
if ( | const doc = parser.parseFromString(text, 'text/html') | ||
const preElement = doc.querySelector('pre') | |||
if (preElement) { | |||
try { | try { | ||
const data = JSON.parse( | const jsonText = preElement.textContent | ||
const data = JSON.parse(jsonText) | |||
const pages = data.query.pages | const pages = data.query.pages | ||
const pageId = Object.keys(pages)[0] | const pageId = Object.keys(pages)[0] | ||
2025年10月19日 (日) 22:15的版本
| 曲目 | |
|---|---|
|
|
|
| 限制 | |
| 难度 | a |
| 流速 | b |
| MOD | c |
| 其他 | d |
神秘的随机挑战!
| 曲目 | |
|---|---|
|
| |
| 限制 | |
| 难度 | a |
| 流速 | b |
| MOD | c |
| 其他 | d |
User:RedDragon/Test User:RedDragon/Test1 User:RedDragon/Test2