NarrowBlog_PushupComment

小説家になろう感想・活動報告のコメントフォームをコメントの上に押し上げる

目前為 2015-12-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        NarrowBlog_PushupComment
// @namespace   phodra
// @description 小説家になろう感想・活動報告のコメントフォームをコメントの上に押し上げる
// @version     1.2
// @include     http://mypage.syosetu.com/mypageblog/view/userid/*
// @include     http://novelcom.syosetu.com/impression/list/ncode/*
// ==/UserScript==

/*	// AutoPagerize互換用SITEINFO
	{
		url: "^http://mypage\\.syosetu\\.com/mypage",
		nextLink: "//a[@title='next page' or ../@class='blogcomment_r'] | id('my_blog_l')/a[not(//a[../@class='blogcomment_r'])]",
		pageElement: "//div[@class='bloglist'] | id('novellist novelpointlist novelreviewlist')/ul | id('favuser')//li | id('blogbg blog_comment_input')[not(//a[../@class='blogcomment_l'])] | id('blog_comment')",
		exampleUrl: "",
	},
*/

(function (){
	if( location.href.indexOf("blog")>0){
		// 活動報告
		const input = "blog_comment_input";
		const inspos = "blog_comment";
		
		var PushUp = function( elm, pos){
			// 活動報告
			var parent = document.getElementById("main");
			if( elm == null ){
				// コメントフォームをコメント一覧の上に持っていく
				elm = document.getElementById(input);
			}
			if( pos == null ){
				// 通常ならコメントの前、コメントがない場合本文の後
				pos = document.getElementById(inspos);
			}

			if( elm && pos ){
				parent.insertBefore( elm, pos);
				parent.insertBefore( document.createElement("br"), pos);
			}
		};
		PushUp();

		var nodes = {};
		document.addEventListener(
			'AutoPagerize_DOMNodeInserted',
			function(e){
				var node = e.input;
				nodes[node.id] = node;
			}, false
		);
		document.addEventListener(
			'GM_AutoPagerizeNextPageLoaded',
			function(e){
				if( nodes[inspos] && nodes[input] ){
					PushUp( nodes[input], nodes[inspos] );
					nodes={};
				}
			}, false
		);
	}else{
		// 小説感想ページ
		var comment = "#hyoukalan";
		var $comment = $(comment);

		// 移動
		var $pos = $("h1:eq(0)");
		$pos.before($comment);
		$pos.before($("<hr>"));
		
		// 横幅いっぱいにする
		$("textarea," + comment).css(
			{
				'box-sizing': 'border-box',
				'width': '100%'
			}
		);

		// "▽感想を書く"を消去
		$(".input").hide();
	}
})();