User:K599/Niconico.js

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

//Loading this JavaScript allows Niconico videos to be embedded by inserting the following code: // //data-id: The ID of the video, which is found after the "watch/" in the video's URL. //data-from: Set when the video starts in seconds from the start.

mw.hook('wikipage.content').add(function($content) {   $content.find('.niconico:not(.loaded)').each(function { var $this = $(this), data = $this.data, uri = new mw.Uri('https://embed.nicovideo.jp/watch/');

uri.path += String(data.id || '').trim + '/script'; uri.query = { w: String(data.width || '').trim, h: String(data.height || '').trim, from: String(data.from || '').trim };       $this.html(            $(' ', { type: 'application/javascript', src: uri.toString })       ).addClass('loaded'); }); });