User:K599/TwitchPlayer.js

//Author: K599 / Kelvs599

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

//Loading this JavaScript allows Twitch live streams/videos to be embedded by inserting the following code: // //Explanations for each parameter can be found on https://dev.twitch.tv/docs/embed/video-and-clips (note that this script sets "parent" automatically)

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

uri.query = { channel: String(data.channel || '').trim, video: String(data.video || '').trim, collection: String(data.collection || '').trim, autoplay: String(data.autoplay ?? '').trim, muted: String(data.muted ?? '').trim, time: String(data.time || '').trim, parent: mw.config.get('wgServerName') };       $this.html(            $(' ', { width: String(data.width || '').trim, height: String(data.height || '').trim, src: uri.toString, frameborder: '0', scrolling: 'no', allowfullscreen: 'true' })       ).addClass('loaded'); }); });