# nlフィルタ定義(文字コード判定用なのでこの行は削除しないこと)

#----------------------------------------------------------------------------------------
[Replace]
Name = popThumb_FA：watch視聴時にdataコンテナ更新&作成
URL = www\.nicovideo\.jp/watch/
Match<
(?=</body>)
>
Replace<
<script type="text/javascript">
\$(function(){
	const ns=window.WatchApp.namespace;
	ns.init.PlayerInitializer.playerAreaConnector.addEventListener("onVideoInitialized",function(){
		if (!(window.popThumb&&popThumb.addEvent))return alert('[popThumb_FA.js] not found.');
		const NPC=ns.model.player.NicoPlayerConnector,
			  fV=NPC.playerInitializeModel.flashVars,vD=fV.videoDetail,wIM=NPC.watchInfoModel,uI=wIM.uploaderInfo,
			  tL=vD.tagList,area=vD.area,
			  p=window.popThumb,data=p.data;
		var tags=[];
		for(var i=tL.length;i--;){
			var t=tL[i];
			tags.unshift({
				"text":t.tag,
				"category":(t.cat?1:null),
				"dic":(t.dic?1:null),
				"lock":(t.lck=="1"?1:null),
				"domain":area,
				"area":area
			});
		}
		var D={
			"title":vD.title_original,
			"description":wIM.description,
			"description_videoarray":wIM.description,
			"view_counter":vD.viewCount,
			"mylist_counter":vD.mylistCount,
			"comment_counter":vD.commentCount,
			"tags":tags,
			"user_id":uI.id,
			"user_nickname":uI.nickname,
		},D2,obj;
		if(obj=data["obj_"+vD.v]){D2=obj[1];}else{
			obj=vD.length;
			D2={
				"thumbnail_url":vD.thumbnail,
				"deleted":fV.deleted-0,
				"video_id":vD.v,
				"first_retrieve":vD.postedAt.replace(/[/]/g,'-').replace(' ','T')+'+00:00',
				"length_in_seconds":obj,
				"length":("0"+((obj/60)|0)).slice(-2)+":"+("0"+(obj%60)).slice(-2),
				"movie_type":fV.movie_type,
				"size_low":null,
				"usingAPI":{}
			};
		}
		for(var j in D)D2[j]=D[j];
		data["obj_"+vD.v]=['object',D2];
		if(typeof p.save==="function")window.setTimeout(p.save,1000);
	}
)});
</script><CRLF>
>