打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

用户:RedDragon/Test1:修订间差异

来自Rizline中文维基
第2行: 第2行:


<html>
<html>
<div id="user-page">
<div id="user-profile">
     <p></p>
     <p></p>
</div>
</div>


<script>
<script>
document.addEventListener('DOMContentLoaded', function() {
    document.addEventListener('DOMContentLoaded', function () {
    var profilePageUrl = '/wiki/User_profile:RedDragon'
        var profilePageUrl = '/index.php/User_profile:RedDragon'
    var container = document.getElementById('user-page')
        var container = document.getElementById('user-profile')


    fetch(profilePageUrl)
        fetch(profilePageUrl)
        .then(function(response) {
            .then(function (response) {
            if (!response.ok) {
                if (!response.ok) {
                throw new Error('网络响应异常 状态码:' + response.status)
                    throw new Error('网络响应异常 状态码:' + response.status)
            }
            return response.text()
        })
        .then(function(htmlString) {
            var parser = new DOMParser()
            var doc = parser.parseFromString(htmlString, 'text/html')
 
            var stylesheets = doc.querySelectorAll('link[rel="stylesheet"]')
            var head = document.getElementsByTagName('head')[0]
           
            stylesheets.forEach(function(sheet) {
                var href = sheet.href
                var existing = document.querySelector('link[href="' + href + '"]')
                if (!existing && href) {
                    var newSheet = sheet.cloneNode(true)
                    if (newSheet.href.startsWith('/')) {
                        newSheet.href = window.location.protocol + '//' + window.location.host + newSheet.href
                    }
                    head.appendChild(newSheet)
                 }
                 }
                return response.text()
             })
             })
            .then(function (htmlString) {
                var parser = new DOMParser()
                var doc = parser.parseFromString(htmlString, 'text/html')


            var contentArea = doc.getElementById('mw-content-text')
                var contentArea = doc.getElementById('mw-content-text')
            var leftContent = doc.getElementById('user-page-left')
            var rightContent = doc.getElementById('user-page-right')


            if (!contentArea || !leftContent || !rightContent) {
                if (!contentArea) {
                container.style.display = 'none'
                    container.style.display = 'none'
                return
                    return
            }
                }


            container.innerHTML = ''
                var contentClone = contentArea.cloneNode(true)
            var contentClone = contentArea.cloneNode(true)
                container.innerHTML = ''
           
                container.appendChild(contentClone)
            var printfooter = contentClone.querySelector('.printfooter')
            if (printfooter) printfooter.remove()
           
            container.appendChild(contentClone)


            var baseUrl = window.location.protocol + '//' + window.location.host
                var baseUrl = window.location.protocol + '//' + window.location.host
                var links = container.querySelectorAll('a[href^="/"]')


            var links = container.querySelectorAll('a[href^="/"]')
                for (var i = 0; i < links.length; i++) {
            links.forEach(function(link) {
                    var link = links[i]
                if (link.getAttribute('href').startsWith('/')) {
                    if (link.getAttribute('href').startsWith('/')) {
                    link.href = baseUrl + link.getAttribute('href')
                        link.href = baseUrl + link.getAttribute('href')
                    }
                 }
                 }
            })


            var images = container.querySelectorAll('img[src^="/"]')
                var images = container.querySelectorAll('img[src^="/"]')
            images.forEach(function(img) {
                for (var j = 0; j < images.length; j++) {
                if (img.getAttribute('src').startsWith('/')) {
                    var img = images[j]
                    img.src = baseUrl + img.getAttribute('src')
                    if (img.getAttribute('src').startsWith('/')) {
                        img.src = baseUrl + img.getAttribute('src')
                    }
                 }
                 }
             })
             })
        })
            .catch(function (error) {
        .catch(function(error) {
                console.error('获取时出错:', error)
            console.error('获取时出错:', error)
                container.style.display = 'none'
            container.style.display = 'none'
            })
        })
    })
})
</script>
</script>
</html>
</html>

2025年10月18日 (六) 20:32的版本

加入社区

avataravataravataravatar
avataravataravataravatar
avatar