User:K599/Embed-iframe.js

//Author: K599 / Kelvs599

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

//Loading this JavaScript allows s to be embedded by inserting the following code: // //Explanations for each parameter can be found on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe //Note that the will only load if it follows Miraheze's Content Security Policy, which can be found on https://github.com/miraheze/puppet/blob/master/modules/varnish/data/csp_whitelist.yaml

mw.hook('wikipage.content').add(function($content) {   $content.find('.embed-iframe:not(.loaded)').each(function { var $this = $(this), data = $this.data;

$this.html(           $(' ', { src: String(data.src || '').trim, style: 'width: ' + (typeof data.width === 'number' ? data.width + 'px' : String(data.width || '300px').trim) + '; height: ' + (typeof data.height === 'number' ? data.height + 'px' : String(data.height || '150px').trim) + '; border: none;', allow: String(data.allow || '').trim })       ).addClass('loaded'); }); });