小説家になろう活動報告のコメントフォームをコメントの上に押し上げる
当前为
// ==UserScript==
// @name NarrowBlog_PushupComment
// @namespace phodra
// @description 小説家になろう活動報告のコメントフォームをコメントの上に押し上げる
// @version 1.1
// @include http://mypage.syosetu.com/mypageblog/view/userid/*
// ==/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 (){
const object = "blog_comment_input";
const before = "blog_comment";
var PushUp = function( elm, tgt){
// 活動報告
var parent = document.getElementById("main");
if( elm == null ){
// コメントフォームをコメント一覧の上に持っていく
elm = document.getElementById(object);
}
if( tgt == null ){
// 通常ならコメントの前、コメントがない場合本文の後
tgt = document.getElementById(before);
}
if( elm && tgt ){
parent.insertBefore( elm, tgt);
parent.insertBefore( document.createElement("br"), tgt);
}
};
PushUp();
var nodes = {};
document.addEventListener(
'AutoPagerize_DOMNodeInserted',
function(e){
var node = e.target;
nodes[node.id] = node;
}, false
);
document.addEventListener(
'GM_AutoPagerizeNextPageLoaded',
function(e){
if( nodes[before] && nodes[object] ){
PushUp( nodes[object], nodes[before] );
nodes={};
}
}, false
);
})();