MediaWiki:Gadget-discord.js

From Support Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * Discord gadget from the Undertale Yellow Wiki by KockaAdmiralac.
 * It is intended to be a rather simplistic one, with a simple image displayed
 * in the wiki.gg navigation bar. This is because big widgets take up more
 * bandwidth and are more likely to be percieved as ads by the users, (I have no
 * data to back this up) and also because there is no meaningful place to put
 * such a widget.
 */
// Change this to a non-expiring invite link to your wiki server.
// Pro tip: make it different from other invite links to your server, so you can
//          track how many users enter through the widget.
var inviteLink = 'https://discord.gg/rTnST57tuW';
// Change this to your server's ID. You get your server's ID when visiting the
// Server Settings > Widget screen. Make sure to also enable it on that same
// screen!
var serverId = '951501892553424917';

var $link = $(
    mw.util.addPortletLink(
        'p-personal',
        inviteLink,
        'Discord server',
        'pt-discord',
        'The wiki\'s Discord server',
        '9',
        $('#pt-userpage, #pt-anonuserpage').get(0)
    )
)
    .find('a')
    .html($('<img>', {
        src: 'https://discord.com/api/guilds/' + serverId + '/widget.png?style=shield',
        title: 'The wiki\'s Discord server'
    }));
$('.mobile-menu').prepend($link.clone());