查看“Widget:Reader”的源代码
刷
历
编
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您可以查看和复制此页面的源代码。
xxxxxxxxxx
27
1
<includeonly><script>
2
function display_reader_name() {
3
var viewerElements = document.querySelectorAll('.the-viewer-username');
4
if (viewerElements.length > 0) {
5
fetch('https://line3-h5-pc-api.biligame.com/game/user/myinfo', {credentials: 'include'})
6
.then(function (response) {
7
return response.json();
8
})
9
.then(function (data) { // 填充数据
10
Array.prototype.forEach.call(viewerElements, function (element) {
11
element.textContent = data.data.uname;
12
});
13
})
14
.catch(function (error){
15
console.error('Gadget-ViewerName:There has been a problem with your fetch operation:', error);
16
});
17
}
18
}
19
20
if (document.readyState === "loading") {
21
document.addEventListener("DOMContentLoaded", display_reader_name);
22
} else {
23
display_reader_name();
24
}
25
</script>
26
</includeonly><noinclude>显示读者用户名的脚本,配合[[模板:Reader]]使用(现在由Main.js内置)</noinclude>
27
返回至“Widget:Reader”。