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. Go to your MediaWiki:Common.js, or wherever you're loading your JS, and either copy this page's code or insert the following line: //mw.loader.load('https://meta.miraheze.org/w/index.php?title=User:K599/Embed-iframe.js&action=raw&ctype=text/javascript');

//You embed by inserting the following code: // //The full list of parameters is as follows: // //Explanations for each parameter can be found on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe //Default width and height is 300x150. //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 //If the src you want to load isn't on the CSP whitelist, open a task on phabricator (https://phabricator.miraheze.org/) requesting it to be added, then Miraheze staff will review it.

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'); }); });