// ==UserScript==
// @name mamastarbbs2dat
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://mamastar.jp/bbs/comment.do?topicId=*
// @grant none
// ==/UserScript==
//cf.http://mamastar.jp/bbs/comment.do?topicId=3132886&commentNo=513
var piyo = document.evaluate('//div[@class="comment_p piyobox"]', document, null, 7, null);
var dummy = document.createElement("div");
var list = document.createElement("li");
var d_text = "ぴよぴよ";
var d_name = document.createTextNode(d_text);
list.appendChild(d_name);
list.classList.add("comment_name");
dummy.appendChild(list);
//document.body.appendChild(d);
var ul= document.createElement("ul");
var li2 = document.createElement("li");
var d_date = document.createTextNode(d_text);
var dummy2 = document.createElement("div");
li2.appendChild(d_date);
ul.appendChild(li2);
ul.classList.add("item_box_separate_r");
dummy2.appendChild(ul);
for (var i = 0; i < piyo.snapshotLength; i++) {
piyo.snapshotItem(i).innerHTML=piyo.snapshotItem(i).innerHTML+dummy.innerHTML;
piyo.snapshotItem(i).innerHTML=piyo.snapshotItem(i).innerHTML+dummy2.innerHTML;
}
//cf.http://mamastar.jp/bbs/comment.do?topicId=3132886&commentNo=6
//cf2.http://mamastar.jp/bbs/comment.do?topicId=988288&sort=1
var k_id = document.evaluate('//ul[@class="item_box_separate_l"]/li[last()][not(@class)]', document, null, 7, null);
for(var k=0;k<k_id.snapshotLength;k++)
{
k_id.snapshotItem(k).textContent=k_id.snapshotItem(k).textContent+" ";
}
var k_n = document.evaluate('//li[@class="comment_name"]', document, null, 7, null);
for(var x=0;x<k_n.snapshotLength;x++)
{
k_n.snapshotItem(x).textContent=k_n.snapshotItem(x).textContent+" ";
}
var n = document.evaluate('//li[@class="comment_name"]/text()[last()]', document, null, 7, null);
/*var id = document.evaluate('//ul[@class="item_box_separate_l"]/li[last()][not(@class)]/text()', document, null, 7, null);*/
var date = document.evaluate('//ul[@class="item_box_separate_r"]/li[not(@class)]/text()', document, null, 7, null);
var hb = document.evaluate('//div[contains(@class,"comment_p")]/p[1]', document, null, 7, null);
var title = document.evaluate('//h1[@class="topic_title"]/dd/text()', document, null, 7, null);
var gyo;
//var r_honbun;
var t =document.createElement("textarea");
var ntext;
for(var j=0;j<hb.snapshotLength;j++)
{
hb.snapshotItem(j).innerHTML=hb.snapshotItem(j).innerHTML.replace(/<(?!br)(.|\s)*?>/g, '');
//gyo=n.snapshotItem(j).nodeValue+"<>sage<>"+date.snapshotItem(j).nodeValue+"<id_date>ID:"+id.snapshotItem(j).nodeValue+"<>"+hb.snapshotItem(j).innerHTML;
gyo=n.snapshotItem(j).nodeValue+"<>sage<>"+date.snapshotItem(j).nodeValue+"<>"+hb.snapshotItem(j).innerHTML;
if(j==0)
{
gyo=gyo+"<>"+title.snapshotItem(0).nodeValue+"<kaigyo>";
}
else{
gyo=gyo+"<kaigyo>";
}
gyo=gyo.replace(/\n|\s/g,"");
gyo=gyo.replace(/<kaigyo>/g,"\n");
/*gyo=gyo.replace(/<id_date>/g," ");
gyo=gyo.replace(/<kara>/g," ");*/
gyo=gyo.replace(/(\d{2}\/\d{2}\/\d{2})(\d{2})/g,"$1 $2");
//console.log(gyo);
ntext =document.createTextNode(gyo);
t.appendChild(ntext);
}
document.body.appendChild(t);