User:K599/YouTube.js

//Originally from https://crossoverwiki.miraheze.org/wiki/MediaWiki:Gadget-YouTube.js //Code based on https://dev.fandom.com/wiki/MediaWiki:YoutubePlayer/code.js

//Loading this JavaScript allows YouTube videos to be embedded by inserting the following code: // //Explanations for each parameter can be found on https://developers.google.com/youtube/player_parameters //Another explanation can be found on https://crossoverwiki.miraheze.org/wiki/Template:YouTube

mw.hook('wikipage.content').add(function($content) {   $content.find('.youtube:not(.loaded)').each(function { var $this = $(this), data = $this.data, uri = new mw.Uri('https://www.youtube.com/embed/'), id = String(data.id || '').trim, loop = String(data.loop || '').trim, listType = String(data.listtype || '').trim, playlist = String(data.playlist || '').trim;

uri.path += id; uri.query = { autoplay: String(data.autoplay || '').trim, loop: loop, playlist: id && loop === '1' && !playlist ? id : playlist, //if looping a single video, set playlist to id           start: String(data.start || '').trim, end: String(data.end || '').trim, listType: listType ? listType : 'playlist', list: String(data.list || '').trim };       $this.html(            $(' ', { width: String(data.width || '').trim, height: String(data.height || '').trim, src: uri.toString, frameborder: '0', allowfullscreen: 'true', allow: 'fullscreen; autoplay; clipboard-write; picture-in-picture;' })       ).addClass('loaded'); }); });