打开/关闭搜索
搜索
打开/关闭菜单
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/300px-%E6%8F%92%E7%94%BB%E5%9B%BE%E6%A0%87.png" width="300" height="300"> </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 scope="row" class="infobox-label" style="width:90px;background:#ddf;">流速</th> <td class="infobox-data" id="speed-data">b</td> </tr> <tr> <th scope="row" class="infobox-label" style="width:90px;background:#ddf;">MOD</th> <td class="infobox-data" id="mod-data">c</td> </tr> <tr> <th scope="row" class="infobox-label" style="width:90px;background:#ddf;">其他</th> <td class="infobox-data" id="other-data">d</td> </tr> </tbody> </table> <script> document.addEventListener('DOMContentLoaded', function () { const encodedUrl = 'https://rizwiki.cn/api.php?action=query%26titles=曲目列表%26prop=revisions%26rvprop=content%26format=json' const decodedUrl = decodeURIComponent(encodedUrl) fetch(decodedUrl) .then(function (r) { return r.json() }) .then(function (data) { if (data.query) { if (data.query.pages) { const pages = data.query.pages const pageId = Object.keys(pages)[0] const wikitext = pages[pageId].revisions[0]['*'] const songs = parseSongsFromWikitext(wikitext) if (songs.length > 0) { loadSongColors(songs[Math.floor(Math.random() * songs.length)]) } else { useMockData() } } else { useMockData() } } else { useMockData() } }) .catch(function (e) { console.error('获取曲目列表失败:', e) useMockData() }) }) function parseSongsFromWikitext(wikitext) { const songs = [] const rows = wikitext.split('|-') for (let i = 1; i < rows.length; i++) { const row = rows[i] const columns = row.split('\n').filter(function (col) { return col.trim().startsWith('|') }) if (columns.length >= 7) { const imageMatch = columns[0].match(/\[\[文件:([^|\]]+)/) const titleMatch = columns[1].match(/\[\[([^|\]]+)/) if (imageMatch) { if (titleMatch) { const song = { image: imageMatch[1].trim(), title: titleMatch[1].trim(), author: columns[2].replace(/^\|/, '').trim(), duration: columns[3].replace(/^\|/, '').trim(), ez: columns[4].replace(/^\|/, '').trim(), hd: columns[5].replace(/^\|/, '').trim(), in: columns[6].replace(/^\|/, '').trim() } if (song.title) { if (song.title !== '') { if (song.title !== '?') { songs.push(song) } } } } } } } return songs } function loadSongColors(song) { const encodedUrl = `https://rizwiki.cn/api.php?action=query%26titles=${encodeURIComponent(song.title)}%26prop=revisions%7Cpageimages%26rvprop=content%26pithumbsize=300%26format=json` const decodedUrl = decodeURIComponent(encodedUrl) fetch(decodedUrl) .then(function (r) { return r.json() }) .then(function (data) { const pages = data.query.pages const pageId = Object.keys(pages)[0] const pageData = pages[pageId] if (!pageData.revisions) { throw new Error('页面不存在') } const wikitext = pageData.revisions[0]['*'] const styles = parseStylesFromWikitext(wikitext) let imageUrl = null if (pageData.thumbnail) { if (pageData.thumbnail.source) { imageUrl = pageData.thumbnail.source } } updateSongInfo(song, { titleStyle: styles.title || '#94E1FF', headerStyle: styles.header || '#A3E5FF', labelStyle: styles.label || '#B2E9FE', imageUrl: imageUrl, pageUrl: `https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}` }) }) .catch(function (e) { console.error('获取曲目颜色失败:', e) updateSongInfo(song, { titleStyle: '#94E1FF', headerStyle: '#A3E5FF', labelStyle: '#B2E9FE', imageUrl: null, pageUrl: `https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}` }) }) } function parseStylesFromWikitext(wikitext) { const styles = {} const color1Match = wikitext.match(/\|color1\s*=\s*([^\n}]+)/) const color3Match = wikitext.match(/\|color3\s*=\s*([^\n}]+)/) const color4Match = wikitext.match(/\|color4\s*=\s*([^\n}]+)/) if (color1Match) styles.title = color1Match[1].trim() if (color3Match) styles.header = color3Match[1].trim() if (color4Match) styles.label = color4Match[1].trim() return styles } function updateSongInfo(song, data) { document.querySelector('.infobox-title th').textContent = song.title document.querySelector('.infobox-title th').style.background = data.titleStyle document.querySelector('.infobox-header th').style.background = data.headerStyle var labelElements = document.querySelectorAll('.infobox-label') for (var i = 0; i < labelElements.length; i++) { labelElements[i].style.background = data.labelStyle } var container = document.querySelector('.infobox td[colspan="2"]') container.innerHTML = '<a href="' + data.pageUrl + '" target="_blank"><img id="song-image" width="300" height="300" src="' + (data.imageUrl || '/images/thumb/4/41/插画图标.png/300px-插画图标.png') + '"></a>' 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:#53D6FF;padding:0 0.80em;margin:0.1em 0.50em">无限制</span>' ] generateRandomRestrictions() } function createDiffSpan(diff, level) { var 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:' + colors[diff] + ';padding:0 0.80em;margin:0.1em 0.50em">' + diff + ' ' + level + '</span>' } function generateRandomRestrictions() { // 流速选项 var speeds = Array(40).fill("无限制").concat(Array.from({ length: 91 }, function (_, i) { return (i + 10) / 10 })) // 随机流速 document.getElementById('speed-data').textContent = speeds[Math.floor(Math.random() * speeds.length)] // 随机难度 document.getElementById('difficulty-data').innerHTML = window.difficultyArray[Math.floor(Math.random() * window.difficultyArray.length)] // MOD权重配置 var modOptions = [ { name: "无MOD", weight: 4 }, { name: "镜像模式", weight: 1 }, { name: "保护模式", weight: 1 }, { name: "Bad保护模式", weight: 1 }, { name: "特殊计量条", weight: 1 }, { name: "隐藏计量条", weight: 1 } ] // 其他限制权重配置 var otherOptions = [ { name: "无限制", weight: 6 }, { name: "静音", weight: 1 }, { name: "单手", weight: 1 }, { name: "手持", weight: 1 }, { name: "Bad数比Hit数多", weight: 1 }, { name: "Combo低于50", weight: 1 }, { name: "全拆打法", weight: 1 }, { name: "全换打法", weight: 1 }, { name: "禁止出张", weight: 1 } ] // 随机MOD var selectedMods = selectWeightedItems(modOptions, 0.3, "无MOD") // 特殊计量条处理 var hasSpecial = selectedMods.includes("特殊计量条") if (hasSpecial) { var specialRates = ["特殊计量条100%", "特殊计量条110%", "特殊计量条120%"] selectedMods = selectedMods.filter(function (m) { return m !== "特殊计量条" }) selectedMods.push(specialRates[Math.floor(Math.random() * specialRates.length)]) } // 随机其他限制 var selectedOthers = selectWeightedItems(otherOptions, 0.8, "无限制") updateRestrictionElement('mod-data', selectedMods) updateRestrictionElement('other-data', selectedOthers) } // 加权随机选择函数 // options: 选项数组 // singleProbability: 只选择一个项的概率 // excludeItem: 选择多个时要排除的项 function selectWeightedItems(options, singleProbability, excludeItem) { var selectedItems = [] if (Math.random() < singleProbability) { var weightedOptions = [] for (var i = 0; i < options.length; i++) { for (var j = 0; j < options[i].weight; j++) { weightedOptions.push(options[i].name) } } selectedItems = [weightedOptions[Math.floor(Math.random() * weightedOptions.length)]] } else { var availableOptions = options.filter(function (opt) { return opt.name !== excludeItem }) var shuffled = availableOptions.slice().sort(function () { return Math.random() - 0.5 }) var count = Math.floor(Math.random() * 3) + 2 // 2-4个项 selectedItems = shuffled.slice(0, Math.min(count, availableOptions.length)).map(function (opt) { return opt.name }) } if (selectedItems.includes(excludeItem)) { selectedItems = [excludeItem] } return selectedItems } function updateRestrictionElement(elementId, items) { var element = document.getElementById(elementId) if (items.length === 1) { element.textContent = items[0] } else { element.innerHTML = '<p>' + items.join('<br>') + '</p>' } } function useMockData() { updateSongInfo({ title: "Pastel Lines", ez: "1", hd: "6", in: "11" }, { titleStyle: '#94E1FF', headerStyle: '#A3E5FF', labelStyle: '#B2E9FE' }) } </script> </html> 神秘的随机挑战! Ver.1.2 <pre> {{Infobox |name = 随机挑战 |title = 曲目 |titlestyle = background:#ccc |image = [[File:插画图标.png|100px]] |imagestyle = |headerstyle = background:#ccf |labelstyle = background:#ddf |header1 = 限制 |label2 = 难度 |data2 = a |label3 = 流速 |data3 = b |label4 = MOD |data4 = c |label5 = 其他 |data5 = d |data5 = d }} </pre> ---- [[User:RedDragon/Test]] [[User:RedDragon/Test1]] [[User:RedDragon/Test2]]
返回
用户:RedDragon/Test2
。
查看“︁用户:RedDragon/Test2”︁的源代码
来自Rizline中文维基