Fandom Developers Wiki
Advertisement

UserFunctions provides functions similar to Mw:Extension:UserFunctions. See Usage for more details.

ATTENTION: The script may not work on mobile skin.

Installation

Usage

Using HTML class attribute user-functions or UserFunctions to call the functions, any <tag> is okay.

if-logged-in

<span class="user-functions" data-if-logged-in="{boolean}">[content]</span>
  • "true": The content will be displayed when the viewer is logged in.
  • "false": The content will be displayed when the viewer is not logged in.
demo

you are logged inyou are NOT logged in

username

<!-- basic -->
<span class="user-functions" data-username>[content]</span>
<!-- with-link -->
<span class="user-functions" data-username data-wiki-link>[link text]</span>

The content will be replaced by viewer's user name.

demo
  • User name:
  • With link:
  • Link with text: Link text here!

if-username

<span class="user-functions" data-if-username="{string | string[]}">[content]</span>

The content will be displayed when the viewer's user name matches the settings.

demo

You areare NOT 机智的小鱼君~

if-usergroup

<span class="user-functions" data-if-usergroup="{string | string[]}">[content]</span>

The content will be displayed when the viewer's user groups matches the settings.

demo

You areare NOT in the "sysop" group!


Data typings

boolean

  • false: false no 0 will give false
  • true: any other value will give true
examples
<!-- true -->
<span class="user-functions" data-if-logged-in>logged in</span>
<span class="user-functions" data-if-logged-in="">logged in</span>
<span class="user-functions" data-if-logged-in="whatever">logged in</span>
<!-- false -->
<span class="user-functions" data-if-logged-in="false">not logged in</span>
<span class="user-functions" data-if-logged-in="no">not logged in</span>
<span class="user-functions" data-if-logged-in="0">not logged in</span>

string[] (array of strings)

  • Inputed string will be split by |
  • String starts with ! means false
example

foo|!bar{foo: true, bar: false}


Text above can be found here (edit)


Advertisement