打开/关闭搜索
搜索
打开/关闭菜单
139
836
236
7082
Rizline中文维基
导航
首页
最近更改
随机页面
♪ 随机曲目
@ 邮件联系
MediaWiki帮助
特殊页面
上传文件
Rizline中文维基
方针
格式手册
著作权
帮助
维基入门
基础语法
图像
表格
介绍
机制
设置
活动
收藏
挑战
版本更新概要
列表
曲目列表
插画作者列表
曲目作者列表
Rizcard列表
版式列表
称号列表
成就列表
外部链接
Rizline官方bilibili账号
Rizline中文维基bilibili账号
排错
特殊页面
封禁用户
站点统计
状态检测
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
中文(简体)
个人工具
创建账号
登录
查看“︁用户:RedDragon/Test2”︁的源代码
来自Rizline中文维基
查看
阅读
查看源代码
查看历史
associated-pages
用户页
讨论
更多操作
←
用户:RedDragon/Test2
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于这些用户组的用户执行:
管理员
、emailconfirmed
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
<html> <table class="infobox" cellspacing="3" style="border-collapse:separate;border-spacing:2px;float:right;"> <tbody> <tr class="infobox-title"> <th colspan="2" style="padding:8px;background:#ccc;">曲目</th> </tr> <tr> <td colspan="2" style="text-align:center;"> <img id="song-image" src="/images/thumb/4/41/%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png/200px-%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png" width="200" height="200"> </td> </tr> <tr class="infobox-header"> <th colspan="2" style="padding:8px;background:#ccf;">限制</th> </tr> <tr> <th scope="row" class="infobox-label" style="width:90px;background:#ddf;">难度</th> <td class="infobox-data" id="difficulty-data">a</td> </tr> <tr> <th sc document.addEventListener('DOMContentLoaded', function () { fetch('https://rizwiki.cn/wiki/%E6%9B%B2%E7%9B%AE%E5%88%97%E8%A1%A8') .then(response => { if (!response.ok) { throw new Error('网络响应不正常') } return response.text() }) .then(html => { const parser = new DOMParser() const doc = parser.parseFromString(html, 'text/html') const songs = [] const tables = doc.querySelectorAll('.wikitable') let targetTable = null tables.forEach(table => { const headers = table.querySelectorAll('th') let hasRequiredHeaders = false headers.forEach(header => { const text = header.textContent.trim() if (text.includes('标题') || text.includes('曲目') || text.includes('名称')) { hasRequiredHeaders = true } }) if (hasRequiredHeaders) { targetTable = table } }) if (targetTable) { const rows = targetTable.querySelectorAll('tr') rows.forEach((row, index) => { if (index === 0) return const cells = row.querySelectorAll('td, th') if (cells.length >= 4) { let titleCell, ezCell, hdCell, inCell if (cells.length >= 7) { titleCell = cells[1] ezCell = cells[4] hdCell = cells[5] inCell = cells[6] } else if (cells.length >= 4) { titleCell = cells[0] ezCell = cells[1] hdCell = cells[2] inCell = cells[3] } if (titleCell) { const song = { title: titleCell.textContent.trim(), ez: ezCell ? ezCell.textContent.trim() : '?', hd: hdCell ? hdCell.textContent.trim() : '?', in: inCell ? inCell.textContent.trim() : '?' } const img = titleCell.querySelector('img') if (img) { song.image = img.src || img.getAttribute('data-src') } if (song.title && song.title !== '?' && song.title !== '') { songs.push(song) } } } }) } console.log('找到曲目:', songs) if (songs.length > 0) { const randomSong = songs[Math.floor(Math.random() * songs.length)] console.log('随机选择:', randomSong) loadSongColors(randomSong) } else { useMockData() } }) .catch(error => { console.error('获取曲目列表失败:', error) useMockData() }) }) function loadSongColors(song) { console.log('正在获取曲目颜色:', song.title) fetch(`https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}`) .then(response => { if (!response.ok) { throw new Error('曲目页面不存在') } return response.text() }) .then(html => { const parser = new DOMParser() const doc = parser.parseFromString(html, 'text/html') const titleElem = doc.querySelector('.infobox-title') const headerElem = doc.querySelector('.infobox-header') const labelElem = doc.querySelector('.infobox-label') const titleStyle = titleElem ? getComputedColor(titleElem) : null const headerStyle = headerElem ? getComputedColor(headerElem) : null const labelStyle = labelElem ? getComputedColor(labelElem) : null console.log('获取到的颜色:', { titleStyle, headerStyle, labelStyle }) updateSongInfo(song, { titleStyle: titleStyle || '#94E1FF', headerStyle: headerStyle || '#A3E5FF', labelStyle: labelStyle || '#B2E9FE' }) }) .catch(error => { console.error('获取曲目颜色失败:', error) updateSongInfo(song, { titleStyle: '#94E1FF', headerStyle: '#A3E5FF', labelStyle: '#B2E9FE' }) }) } function getComputedColor(element) { const tempDiv = document.createElement('div') tempDiv.style.cssText = element.style.cssText document.body.appendChild(tempDiv) const computedStyle = window.getComputedStyle(tempDiv) const bgColor = computedStyle.backgroundColor document.body.removeChild(tempDiv) if (bgColor.startsWith('rgb')) { const rgb = bgColor.match(/\d+/g) if (rgb && rgb.length === 3) { return '#' + ('0' + parseInt(rgb[0]).toString(16)).slice(-2) + ('0' + parseInt(rgb[1]).toString(16)).slice(-2) + ('0' + parseInt(rgb[2]).toString(16)).slice(-2) } } return bgColor } function updateSongInfo(song, styles) { const titleElement = document.querySelector('.infobox-title th') titleElement.textContent = song.title titleElement.style.background = styles.titleStyle const imageElement = document.getElementById('song-image') if (song.image) { imageElement.src = song.image } document.querySelector('.infobox-header th').style.background = styles.headerStyle const labelElements = document.querySelectorAll('.infobox-label') labelElements.forEach(label => { label.style.background = styles.labelStyle }) window.difficultyArray = [ createDiffSpan("EZ", song.ez), createDiffSpan("HD", song.hd), createDiffSpan("IN", song.in), '<span style="width: max-content;text-align:center;display:inline-block;border-radius:1em;color:white;background-color:#53D6FF;padding:0 0.80em;margin:0.1em 0.50em;">无限制</span>' ] generateRandomRestrictions() } function createDiffSpan(diff, level) { const colors = { EZ: '#57E4C4', HD: '#FDBA61', IN: '#FE8661' } return `<span style="width: max-content;text-align:center;display:inline-block;border-radius:1em;color:white;background-color:${colors[diff]};padding:0 0.80em;margin:0.1em 0.50em;">${diff} ${level}</span>` } function generateRandomRestrictions() { const difficultyElement = document.getElementById('difficulty-data') const randomDifficulty = window.difficultyArray[Math.floor(Math.random() * window.difficultyArray.length)] difficultyElement.innerHTML = randomDifficulty const speedOptions = ["无限制", "无限制", "无限制"] for (let i = 10; i <= 100; i++) speedOptions.push((i / 10).toFixed(1)) document.getElementById('speed-data').textContent = speedOptions[Math.floor(Math.random() * speedOptions.length)] const modOptions = ["无MOD"] const otherOptions = ["无限制"] document.getElementById('mod-data').textContent = modOptions[Math.floor(Math.random() * modOptions.length)] document.getElementById('other-data').textContent = otherOptions[Math.floor(Math.random() * otherOptions.length)] } function useMockData() { console.log('使用模拟数据') const mockSong = { title: "Pastel Lines", ez: "1", hd: "6", in: "11" } updateSongInfo(mockSong, { titleStyle: '#94E1FF', headerStyle: '#A3E5FF', labelStyle: '#B2E9FE' }) } function regenerateChallenge() { location.reload() } </script> </html> 神秘的随机挑战! ---- [[User:RedDragon/Test]] [[User:RedDragon/Test1]] [[User:RedDragon/Test2]]
返回
用户:RedDragon/Test2
。
查看“︁用户:RedDragon/Test2”︁的源代码
来自Rizline中文维基