MediaWiki:Gadget-YouTube.js

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

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; if (id === '') { console.warn('YouTube ID is not defined.'); return; }       uri.path += id; uri.query = { autoplay: String(data.autoplay || '').trim, loop: loop, playlist: loop === '1' ? id : '', start: String(data.start || '').trim, end: String(data.end || '').trim, 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' + (loop ? '; autoplay' : '') })       ).addClass('loaded'); }); });