User:K599/Niconico.js

//Author: K599 / Kelvs599

//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; uri.query = { from: String(data.from || '').trim };       $this.html(            $(' ', { width: String(data.width || '').trim, height: String(data.height || '').trim, src: uri.toString, frameborder: '0', allowfullscreen: 'true' })       ).addClass('loaded'); }); });