User:K599/Discord.js

//Author: K599 / Kelvs599

//Code based on https://dev.fandom.com/wiki/MediaWiki:YoutubePlayer/code.js

//Loading this JavaScript allows Discord widgets to be embedded. Go to your MediaWiki:Common.js, or wherever you're loading your JS, and either copy this page's code or insert the following line: //mw.loader.load('https://meta.miraheze.org/w/index.php?title=User:K599/Discord.js&action=raw&ctype=text/javascript');

//You embed by inserting the following code: // //The full list of parameters is as follows: // //data-id: The server ID of your Discord server, found in server settings under the widget tab. //data-theme: The theme of the widget, can be either "dark" (default) or "light". //Default width and height is 350x500.

mw.hook('wikipage.content').add(function($content) {   $content.find('.discord:not(.loaded)').each(function { var $this = $(this), data = $this.data, uri = new mw.Uri('https://discord.com/widget/');

uri.query = { id: String(data.id || '').trim, theme: String(data.theme || '').trim };

$this.html(           $(' ', { src: uri.toString, style: 'width: ' + (typeof data.width === 'number' ? data.width + 'px' : String(data.width || '350px').trim) + '; height: ' + (typeof data.height === 'number' ? data.height + 'px' : String(data.height || '500px').trim) + '; border: none;', allowtransparency: 'true' })       ).addClass('loaded'); }); });