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

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

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


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


        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 leftContent = doc.getElementById('user-page-left')
                var rightContent = doc.getElementById('user-page-right')
            var rightContent = doc.getElementById('user-page-right')


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


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


                var contentClone = contentArea.cloneNode(true)
            var baseUrl = window.location.protocol + '//' + window.location.host


                var printfooter = contentClone.querySelector('.printfooter')
            var links = container.querySelectorAll('a[href^="/"]')
                 if (printfooter) printfooter.remove()
            links.forEach(function(link) {
                 if (link.getAttribute('href').startsWith('/')) {
                    link.href = baseUrl + link.getAttribute('href')
                }
            })


                container.appendChild(contentClone)
            var images = container.querySelectorAll('img[src^="/"]')
 
            images.forEach(function(img) {
                var baseUrl = window.location.protocol + '//' + window.location.host
                if (img.getAttribute('src').startsWith('/')) {
 
                    img.src = baseUrl + img.getAttribute('src')
                var links = container.querySelectorAll('a[href^="/"]')
                 }
                links.forEach(function (link) {
                    if (link.getAttribute('href').startsWith('/')) {
                        link.href = baseUrl + link.getAttribute('href')
                    }
                })
 
                var images = container.querySelectorAll('img[src^="/"]')
                images.forEach(function (img) {
                    if (img.getAttribute('src').startsWith('/')) {
                        img.src = baseUrl + img.getAttribute('src')
                    }
                 })
             })
             })
            .catch(function (error) {
        })
                console.error('获取时出错:', error)
        .catch(function(error) {
                container.style.display = 'none'
            console.error('获取时出错:', error)
            })
            container.style.display = 'none'
    })
        })
 
})
</script>
</script>
</html>
</html>

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

加入社区

avataravataravataravatar
avataravataravataravatar
avatar