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 by inserting the following code: // //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'); }); });