用户:RedDragon/Test2:修订间差异
来自Rizline中文维基
更多操作
小 |
小 |
||
| 第36行: | 第36行: | ||
<script> | <script> | ||
document.addEventListener('DOMContentLoaded', () => { | document.addEventListener('DOMContentLoaded', () => { | ||
fetch('https://rizwiki.cn/api.php?action=query&titles=曲目列表&prop=revisions&rvprop=content&format=json') | |||
fetch | .then(r => r.json()) | ||
.then(r => | |||
.then(data => { | .then(data => { | ||
const pages = data.query.pages | const pages = data.query.pages | ||
| 第57行: | 第56行: | ||
function parseSongsFromWikitext(wikitext) { | function parseSongsFromWikitext(wikitext) { | ||
const songs = [] | const songs = [] | ||
const rowRegex | const rowRegex = /\|\[\[文件:(.*?)\]\]\s*\|\|\s*\[\[(.*?)\]\]\s*\|\|\s*(.*?)\s*\|\|\s*(.*?)\s*\|\|\s*(\d+.*?)\s*\|\|\s*(\d+.*?)\s*\|\|\s*(\d+.*?)(?=\s*\||\s*\|-|\s*\})/g | ||
let match | let match | ||
while ((match = | while ((match = rowRegex.exec(wikitext)) !== null) { | ||
const song = { | const song = { | ||
image: match[1], | image: match[1], | ||
| 第71行: | 第69行: | ||
in: match[7] | in: match[7] | ||
} | } | ||
if (song.title) songs.push(song) | if (song.title && song.title !== '') { | ||
songs.push(song) | |||
} | |||
} | } | ||
return songs | return songs | ||
| 第77行: | 第77行: | ||
function loadSongColors(song) { | function loadSongColors(song) { | ||
fetch(`https://rizwiki.cn/api.php?action=query&titles=${encodeURIComponent(song.title)}&prop=revisions&rvprop=content&format=json | fetch(`https://rizwiki.cn/api.php?action=query&titles=${encodeURIComponent(song.title)}&prop=revisions&rvprop=content&format=json`) | ||
.then(r => | .then(r => r.json()) | ||
.then(data => { | .then(data => { | ||
const pages = data.query.pages | const pages = data.query.pages | ||
const pageId = Object.keys(pages)[0] | const pageId = Object.keys(pages)[0] | ||
if (!pages[pageId].revisions) { | |||
throw new Error('页面不存在') | |||
} | |||
const wikitext = pages[pageId].revisions[0]['*'] | const wikitext = pages[pageId].revisions[0]['*'] | ||
const styles = parseStylesFromWikitext(wikitext) | const styles = parseStylesFromWikitext(wikitext) | ||
updateSongInfo(song, { | updateSongInfo(song, { | ||
| 第90行: | 第92行: | ||
headerStyle: styles.header || '#A3E5FF', | headerStyle: styles.header || '#A3E5FF', | ||
labelStyle: styles.label || '#B2E9FE', | labelStyle: styles.label || '#B2E9FE', | ||
imageUrl: | imageUrl: `https://rizwiki.cn/images/thumb/${song.image.substring(0, 1)}/${song.image.substring(0, 2)}/${song.image}/300px-${song.image}`, | ||
pageUrl: `https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}` | pageUrl: `https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}` | ||
}) | }) | ||
| 第100行: | 第102行: | ||
headerStyle: '#A3E5FF', | headerStyle: '#A3E5FF', | ||
labelStyle: '#B2E9FE', | labelStyle: '#B2E9FE', | ||
imageUrl: | imageUrl: `https://rizwiki.cn/images/thumb/${song.image.substring(0, 1)}/${song.image.substring(0, 2)}/${song.image}/300px-${song.image}`, | ||
pageUrl: `https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}` | pageUrl: `https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}` | ||
}) | }) | ||
| 第110行: | 第112行: | ||
const titleMatch = wikitext.match(/infobox-title.*?background:(#[0-9a-fA-F]+)/) | const titleMatch = wikitext.match(/infobox-title.*?background:(#[0-9a-fA-F]+)/) | ||
if (titleMatch) styles.title = titleMatch[1] | if (titleMatch) styles.title = titleMatch[1] | ||
const headerMatch = wikitext.match(/infobox-header.*?background:(#[0-9a-fA-F]+)/) | const headerMatch = wikitext.match(/infobox-header.*?background:(#[0-9a-fA-F]+)/) | ||
if (headerMatch) styles.header = headerMatch[1] | if (headerMatch) styles.header = headerMatch[1] | ||
const labelMatch = wikitext.match(/infobox-label.*?background:(#[0-9a-fA-F]+)/) | const labelMatch = wikitext.match(/infobox-label.*?background:(#[0-9a-fA-F]+)/) | ||
if (labelMatch) styles.label = labelMatch[1] | if (labelMatch) styles.label = labelMatch[1] | ||
2025年10月19日 (日) 21:57的版本
| 曲目 | |
|---|---|
|
|
|
| 限制 | |
| 难度 | a |
| 流速 | b |
| MOD | c |
| 其他 | d |
神秘的随机挑战!
| 曲目 | |
|---|---|
|
| |
| 限制 | |
| 难度 | a |
| 流速 | b |
| MOD | c |
| 其他 | d |
User:RedDragon/Test User:RedDragon/Test1 User:RedDragon/Test2