打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
RedDragon留言 | 贡献2025年10月19日 (日) 07:12的版本
<tbody> </tbody>
曲目
               <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">
限制
难度 a
流速 b
MOD c
其他 d

<script>

   mw.loader.using('mediawiki.api').then(function () {
       $(document).ready(function () {
           var apiUrl = mw.config.get('wgScriptPath') + '/api.php'
           $.ajax({
               url: apiUrl,
               data: {
                   action: 'parse',
                   page: '曲目列表',
                   prop: 'text',
                   format: 'json'
               },
               success: function (data) {
                   var content = data.parse.text['*']

var $content = $('

').html(content)
                   var songs = []
                   $content.find('.wikitable tr').each(function (index) {
                       if (index === 0) return
                       var $cells = $(this).find('td, th')
                       if ($cells.length >= 7) {
                           var song = {
                               image: extractImageUrl($cells.eq(0)),
                               title: $cells.eq(1).text().trim(),
                               ez: $cells.eq(4).text().trim(),
                               hd: $cells.eq(5).text().trim(),
                               in: $cells.eq(6).text().trim()
                           }
                           if (song.title) songs.push(song)
                       }
                   })
                   if (songs.length > 0) {
                       var randomSong = songs[Math.floor(Math.random() * songs.length)]
                       loadSongDetails(randomSong)
                   }
               },
               error: function (xhr, status, error) {
                   console.error('获取曲目列表失败:', error)
                   useMockData()
               }
           })
           function extractImageUrl($cell) {
               var $img = $cell.find('img')
               if ($img.length > 0) return $img.attr('src') || $img.attr('data-src')
               return $cell.text().trim()
           }
           function loadSongDetails(song) {
               updateSongInfo(song)
               $.ajax({
                   url: mw.config.get('wgScriptPath') + '/api.php',
                   data: {
                       action: 'parse',
                       page: song.title,
                       prop: 'text',
                       format: 'json'
                   },
                   success: function (data) {
                       var content = data.parse.text['*']
var $content = $('
').html(content)
                       updateStyles({
                           titleStyle: getBackgroundColor($content.find('.infobox-title')) || '#94E1FF',
                           headerStyle: getBackgroundColor($content.find('.infobox-header')) || '#A3E5FF',
                           labelStyle: getBackgroundColor($content.find('.infobox-label')) || '#B2E9FE'
                       })
                   },
                   error: function () {
                       updateStyles({
                           titleStyle: '#94E1FF',
                           headerStyle: '#A3E5FF',
                           labelStyle: '#B2E9FE'
                       })
                   }
               })
           }
           function getBackgroundColor($element) {
               if ($element.length === 0) return null
               var bgColor = $element.css('background-color')
               if (bgColor) {
                   if (bgColor.startsWith('rgb')) {
                       var rgb = bgColor.match(/\d+/g)
                       if (rgb) {
                           if (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) {
               $('.infobox-title th').text(song.title)
               if (song.image) $('#song-image').attr('src', song.image)
               window.difficultyArray = [
                   createDiffSpan("EZ", song.ez),
                   createDiffSpan("HD", song.hd),
                   createDiffSpan("IN", song.in),
                   '无限制'
               ]
               generateRandomRestrictions()
           }
           function createDiffSpan(diff, level) {
               var colors = { EZ: '#57E4C4', HD: '#FDBA61', IN: '#FE8661' }
               return '' + diff + ' ' + level + ''
           }
           function updateStyles(styles) {
               $('.infobox-title th').css('background', styles.titleStyle)
               $('.infobox-header th').css('background', styles.headerStyle)
               $('.infobox-label').css('background', styles.labelStyle)
           }
           function generateRandomRestrictions() {
               var randomDifficulty = window.difficultyArray[Math.floor(Math.random() * window.difficultyArray.length)]
               $('#difficulty-data').html(randomDifficulty)
               var speedOptions = ["无限制", "无限制", "无限制"].concat(Array.from({ length: 91 }, (_, i) => (i + 10) / 10.0))
               $('#speed-data').text(speedOptions[Math.floor(Math.random() * speedOptions.length)])
               var modOptions = ["无MOD", "MIRROR", "HIDDEN", "FLASH"]
               var otherOptions = ["无限制", "仅允许GOOD及以上", "禁止MISS", "连击数≥500"]
               $('#mod-data').text(modOptions[Math.floor(Math.random() * modOptions.length)])
               $('#other-data').text(otherOptions[Math.floor(Math.random() * otherOptions.length)])
           }
           function useMockData() {
               var mockSong = {
                   title: "Pastel Lines",
                   image: "/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",
                   ez: "1",
                   hd: "6",
                   in: "11"
               }
               updateSongInfo(mockSong)
               updateStyles({
                   titleStyle: '#94E1FF',
                   headerStyle: '#A3E5FF',
                   labelStyle: '#B2E9FE'
               })
           }
       })
   })

</script> 神秘的随机挑战!


User:RedDragon/Test User:RedDragon/Test1 User:RedDragon/Test2