您似乎还未注册一个账号?我们强烈推荐您点击此处创建一个账户。|如果您在H萌娘上发现某些内容错误/空缺/不中立,请勇于按右上角编辑按钮!
MediaWiki:Gadget-ShowAvatar.js:修订间差异
跳转到导航
跳转到搜索
imported>=海豚= 无编辑摘要 |
无编辑摘要 |
||
| (未显示2个用户的12个中间版本) | |||
| 第1行: | 第1行: | ||
$(function() { | $(function() { | ||
var img = $('<img>').attr('src', '/ | var username = mw.config.get('wgUserName'); | ||
var pageName = mw.config.get("wgPageName").replace(/^user:/i, ''); | |||
// The new BlueSpice Avatar URL format | |||
var avatarUrlBase = '/rest.php/mws/v1/dynamic-file-dispatcher/userprofileimage?username='; | |||
// 1. Top right personal menu avatar | |||
if ( username ) { | |||
var img = $('<img>') | |||
.attr('src', avatarUrlBase + encodeURIComponent(username)) | |||
.on('error', function() { img.attr('src', '/index.php/Special:FilePath/Moehime.jpg') }) | |||
.css({ | |||
width: '1.2em', | |||
height: '1.2em', | |||
'border-radius': '10px', | |||
'vertical-align': 'middle', | |||
'margin-right': '4px' | |||
}); | |||
var link = $('<a>') | |||
// BlueSpice Avatars uses the UserProfile page for uploads, not Special:上传头像 | |||
.attr('href', '/Special:UserProfile') | |||
.append(img); | |||
$('#pt-userpage').before($('<li id="pt-avatar"></li>').append(link)); | |||
} | |||
// 2. Avatar next to the title on User pages | |||
if (mw.config.get("wgNamespaceNumber") === 2 && !mw.config.get("wgPageName").includes("/")) { | if (mw.config.get("wgNamespaceNumber") === 2 && !mw.config.get("wgPageName").includes("/")) { | ||
$('.ns-2 #firstHeading').prepend( | $('.ns-2 #firstHeading').prepend( | ||
$('<a>').attr({ | $('<a>').attr({ | ||
href: ' | href: '/Special:UserProfile/' + encodeURIComponent(pageName), | ||
title: '查看头像' | title: '查看头像' | ||
}).prepend( | }).prepend( | ||
$('<img>') | $('<img>') | ||
.attr('src', | .attr('src', avatarUrlBase + encodeURIComponent(pageName)) | ||
.css({ | .css({ | ||
width: '1.2em', | width: '1.2em', | ||
2026年7月16日 (四) 21:21的最新版本
$(function() {
var username = mw.config.get('wgUserName');
var pageName = mw.config.get("wgPageName").replace(/^user:/i, '');
// The new BlueSpice Avatar URL format
var avatarUrlBase = '/rest.php/mws/v1/dynamic-file-dispatcher/userprofileimage?username=';
// 1. Top right personal menu avatar
if ( username ) {
var img = $('<img>')
.attr('src', avatarUrlBase + encodeURIComponent(username))
.on('error', function() { img.attr('src', '/index.php/Special:FilePath/Moehime.jpg') })
.css({
width: '1.2em',
height: '1.2em',
'border-radius': '10px',
'vertical-align': 'middle',
'margin-right': '4px'
});
var link = $('<a>')
// BlueSpice Avatars uses the UserProfile page for uploads, not Special:上传头像
.attr('href', '/Special:UserProfile')
.append(img);
$('#pt-userpage').before($('<li id="pt-avatar"></li>').append(link));
}
// 2. Avatar next to the title on User pages
if (mw.config.get("wgNamespaceNumber") === 2 && !mw.config.get("wgPageName").includes("/")) {
$('.ns-2 #firstHeading').prepend(
$('<a>').attr({
href: '/Special:UserProfile/' + encodeURIComponent(pageName),
title: '查看头像'
}).prepend(
$('<img>')
.attr('src', avatarUrlBase + encodeURIComponent(pageName))
.css({
width: '1.2em',
height: '1.2em',
'border-radius': '10px',
padding: '4px'
})
)
);
}
});