Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ShowAvatar #5

Merged
merged 8 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions dist/ShowAvatar/ShowAvatar.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/definition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* HideConversionTab[ResourceLoader|default|requiresES6]|HideConversionTab.css
* InterwikiTips[ResourceLoader|default|requiresES6]|InterwikiTips.css
* LoginToEdit[ResourceLoader|default|dependencies=ext.gadget.i18n,ext.gadget.Util,mediawiki.util,oojs-ui-windows|hidden|requiresES6]|LoginToEdit.js
* ShowAvatar[ResourceLoader|default|requiresES6]|ShowAvatar.js

== browser ==
* AddSectionPlus[ResourceLoader|dependencies=ext.gadget.Util|peers=AddSectionPlus-pagestyles|rights=edit|requiresES6]|AddSectionPlus.js
Expand Down
6 changes: 6 additions & 0 deletions src/ShowAvatar/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* SPDX-License-Identifier: GPL-3.0
* _addText: '{{Gadget Header|license=GPL-3.0}}'
*
* @source <https://github.com/TopRealm/InterfaceCodes/tree/master/src/Gadgets/Appearance/ShowAvatar.css>
*/
35 changes: 35 additions & 0 deletions src/ShowAvatar/ShowAvatar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pt-userpage {
background: none !important;
padding-left: 0 !important;
}

#pt-avatar {
margin-top: 0 !important;
margin-bottom: 0 !important;
}

#pt-avatar img {
width: 2.5em;
border-radius: 50%;
}

.skin-citizen #user-rootpage-avatar {
border-radius: 5px;
top: 8px;
}

.skin-gongbi #user-rootpage-avatar {
border-radius: 10px;
padding: 4px;
}

/* 1.28+ Echo fix */
#p-personal #pt-notifications-alert,
#p-personal #pt-notifications-notice {
margin-top: 0.8em;
}

/* fix:头像位置 */
a[title='查看头像'] {
vertical-align: bottom;
}
31 changes: 31 additions & 0 deletions src/ShowAvatar/ShowAvatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$(() => {
const avatarUrl = new mw.Uri('https://youshou.wiki/');
avatarUrl.query['user'] = mw.config.get('wgPageName').replace(/^user:/i, '');
avatarUrl.path = '/extensions/Avatar/avatar.php';
const imgUrl = new mw.Uri(avatarUrl);
imgUrl.query['user'] = mw.config.get('wgUserName');

if (mw.config.get('wgNamespaceNumber') === 2 && !mw.config.get('wgPageName').includes('/')) {
const hrefUrl = new mw.Uri(avatarUrl);
hrefUrl.path = '/wiki/Special:Viewavatar';
const srcUrl = new mw.Uri(avatarUrl);
$('.ns-2', '#firstHeading').prepend(
$('<a>')
.attr({
href: hrefUrl,
title: '查看头像',
})
.prepend(
$('<img>')
.attr({
src: srcUrl,
id: 'user-rootpage-avatar',
})
.css({
width: '1.2em',
height: '1.2em',
})
)
);
}
});
5 changes: 5 additions & 0 deletions src/ShowAvatar/definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"enable": true,
"description": "<sup><abbr title='默认为所有用户启用'>D</abbr></sup> 显示头像 <small>在用户页标题旁显示用户头像</small>",
"default": true
}
Loading