Skip to content

Instantly share code, notes, and snippets.

@Keyacom
Last active March 7, 2024 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Keyacom/f79e429dfee8e014ef9123fd8357f91c to your computer and use it in GitHub Desktop.
Save Keyacom/f79e429dfee8e014ef9123fd8357f91c to your computer and use it in GitHub Desktop.
Staff highlighter (for Bulbapedia, can be modified for other MediaWiki wikis)
/* New staff highlighting system, utilizing the ::before pseudoelement.
* NOW WORKS FOR JS-UPDATED RECENT CHANGES!
* Made into SCSS for easier updating: https://gist.github.com/Keyacom/f79e429dfee8e014ef9123fd8357f91c
*/
@use 'sass:list';
@use 'sass:meta';
/* Fix Minerva redlink selectors */
a.new > *,
a.new:visited > *,
a.new:hover > * {
color: revert;
}
/* Remove predetermined staff icons */
#bodyContent a[href^="/wiki/User:"] {
background: none !important;
padding-left: initial !important; /* The padding might bother me a bit, so... */
}
// Placeholder selectors, please configure from here!
%jradmin-username {
color: #a60;
font-style: italic;
}
%admin-username {
color: #666;
font-style: italic;
}
%leadboard-username {
color: #6a6;
font-style: italic;
font-weight: bold;
}
%execstaff-username {
color: #22a;
font-style: italic;
font-weight: bold;
}
%bot-username {
color: #232;
font-style: italic;
}
%inactivebot-username {
color: #322;
}
%former-username {
color: #aaa;
}
%before-base {
margin: 0 5px;
padding: 1px 5px;
border-radius: 5px;
color: #ccc;
font-style: initial;
font-weight: bold;
display: inline;
}
%jradmin-before {
content: "JA";
background-color: #c80;
}
%admin-before {
content: "AD";
background-color: #888;
}
%leadboard-before {
content: "LB";
background-color: #8c8;
color: #444;
}
%execstaff-before {
content: "XS";
background-color: #44c; /* fallback in case gradient does not work */
background-image: linear-gradient(to right, #c44, #4c4, #44c, #c44);
}
%bot-before {
content: "BOT";
background-color: #444;
color: #4c4;
}
%inactivebot-before {
content: "BOT";
background-color: #444;
color: #c44;
}
%former-before {
content: "—";
background-color: #ccc;
color: #444;
}
@function normal-attr-selectors($list) {
$ret: ();
@each $user in $list {
$ret: append($ret, '[title=' + meta.inspect("User:" + quote($user)) + "]", comma);
}
@return $ret;
}
@function semicolon-attr-selectors($list) {
$ret: ();
@each $user in $list {
$ret: append($ret, '[title^=' + meta.inspect("User:" + quote($user) + ";") + "]", comma);
}
@return $ret;
}
@function noexist-attr-selectors($list) {
$ret: ();
@each $user in $list {
$ret: append($ret, '[title^=' + meta.inspect("User:" + quote($user) + " (page does not exist)") + "]", comma);
}
@return $ret;
}
@function str-join($list, $delimiter: "") {
$ret: "";
@for $i from 1 to length($list) {
$ret: $ret + nth($list, $i) + $delimiter;
}
@return $ret + nth($list, -1);
}
$users: (
jradmin: (Anzasquiddles, BigDocFan, Nikuriku, Rockapheller, Ruixiang95),
admin: ("4iamking", Blazingfist, Boblers, BthrussellUK, Chosen, "Daniel Carrero", Eridanus, Glik, Landfish7, MisterE13,
Nescientist, "Storm Aurora", TehPerson, Wowy, 神奇超龍),
leadboard: (Abcboy, Ataro, "Frozen Fennec", "Maverick Nate", Pokemaster97, Nuva-kal, SnorlaxMonster, Spriteit, Tiddlywinks),
execstaff: (Archaic, DigBMGF, Enzap, Evkl, Kogoro, MAGNEDETH),
bot: (BulbaBot,),
inactivebot: (MewBot, "Redirect fixer"),
former: (
Adil, Admingeekz, ArcToraphim, Argy, Arty2, Awesomelink234, Barb, Berrenta, "Bikini Miltank", "Blackjack Gabbiani",
Carmenstar97, Celadonkey, Clarky13, Cipher, "CoolPikachu!", "Crystal Talian", CycloneGU, Darkeiya, "Dennou Zenshi",
ElectAbuzzzz, Evie, Fabu-Vinny, "Force Fire", "Funktastic~!", G50, Ht14, Imagize, Iteru, Jello,"Jioruji Derako",
"Jo The Marten", Jshadias, Kenji-girl, "Lady Ariel", Mamady, Masatoshi, Martonimos, Mikuri, Nyoo, Pachirisulover12,
"PAK Man", Pie, Politoed666, PsychicRider, Quagbert, RexRacer, Rockersk08, "Rocket Girl", Soramimi, Shiningpikablu252,
Sketch, Tc26, "The dark lord trombonator", Tina, Toastypk, "Toon Ganondorf", Transfinite, Tsskiller, TTEchidna, "Turtwig A",
Tygerofdanyte, Umeko, "Unown Lord", Urutapu, User142, Vegard, Virtual-Z, Werdnae, "Zesty Cactus", Zeta, "Zhen Lin",
),
);
@each $group, $list in $users {
$normal: normal-attr-selectors($list);
$semi: semicolon-attr-selectors($list);
$noexist: noexist-attr-selectors($list);
:is(
.history-user,
.ns--1 .mw-body,
#mw-diff-otitle2,
#mw-diff-ntitle2,
.mw-warning-with-logexcerpt,
.ns-6 .filehistory,
#mw-mf-userinfo
)
a:not(
:is(
[href*="#"],
[href*="&action=h"],
[href*="&diff="],
[href*="&oldid="],
[href*="&undo="]
)
):is(
#{str-join($normal, ",")},
#{str-join($semi, ",")},
#{str-join($noexist, ",")}
) {
@extend %#{$group}-username;
}
:is(#bodyContent, #mw-mf-userinfo)
a:not(
:is(
[href*="#"],
[href*="&action=h"],
[href*="&diff="],
[href*="&oldid="],
[href*="&undo="]
)
):is(
#{str-join($normal, ",")},
#{str-join($semi, ",")},
#{str-join($noexist, ",")}
)::before {
@extend %before-base;
@extend %#{$group}-before;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment