-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpixivviewcomment_with_autopagerize.user.js
99 lines (93 loc) · 3.03 KB
/
pixivviewcomment_with_autopagerize.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// ==UserScript==
// @name PixivViewComment
// @namespace nanakoso
// @description PIXIVコメント履歴をデフォルトで見れるように Ver. 1.1
// @include http://www.pixiv.net/member_illust.php*mode=medium*
// @include http://www.pixiv.net/novel/show.php*
// ==/UserScript==
function wrap_xmlhttpRequest(options) {
var req = new XMLHttpRequest();
try {
req.onreadystatechange = function () {
if (req.readyState == 4) {
if (req.status == 200) {
if (options.onload) options.onload(req);
}
}
}
req.open(options.method || "GET", options.url, true);
if (options.headers) {
for (key in options.headers) {
req.setRequestHeader(key, options.headers[key]);
}
}
req.send(options.data? options.data : null);
} catch (e) {
if (options.onerror) options.onerror(req, e);
}
}
//alert("start");
function getXPath(xpath){
var ret = document.evaluate(xpath, document, null
, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
var domObj = ret.iterateNext();
return domObj;
}
u_id=getXPath("id('rpc_u_id')").getAttribute('title');//基本変わらないので一回設定すればおk
i_id=getXPath("id('rpc_i_id')").getAttribute('title');//イラスト単位で変わる。urlから取るのも手。
params="i_id="+i_id+"&u_id="+u_id; //docから取るべき?
//alert(params);
wrap_xmlhttpRequest({
url:"./rpc_comment_history.php",
method: "POST",
headers:{
"Content-Type": "application/x-www-form-urlencoded",
},
data: params,
onload: function(obj){
el = getXPath("id('one_comment_area')");
el.innerHTML=obj.responseText;
el.style.display="";
el.style.overflow="visible";
getXPath("id('one_comment_view')").style.display="none";
getXPath("id('one_comment_view2')").style.display="";
},//
})
function viewComment(target, url){
i_id=url.match(/\d+/);
params="i_id="+i_id+"&u_id="+u_id;
//alert(params);
wrap_xmlhttpRequest({
url:"./rpc_comment_history.php",
method: "POST",
headers:{
"Content-Type": "application/x-www-form-urlencoded",
"Referer":url,
},
data: params,
onload: function(obj){
el = document.evaluate(".//div[@id='one_comment_area']",target,null,7,null).snapshotItem(0);
el.innerHTML=obj.responseText;
//alert(el.innerHTML)
el.style.setProperty("display","",null);
el.style.setProperty("overflow","visible",null);
document.evaluate(".//p[@id='one_comment_view']",target,null,7,null).snapshotItem(0).style.setProperty("display","none",null);
document.evaluate(".//p[@id='one_comment_view2']",target,null,7,null).snapshotItem(0).style.setProperty("display","",null);
},
onerror: function(obj){
alert("onerror")
}
})
}
var boot=function(){
window.addEventListener('AutoPagerize_DOMNodeInserted', function(evt){
if(evt.target.className=='works_info'){
viewComment(evt.target, evt.newValue);
}
}, false);
}
if (window.AutoPagerize) {
boot();
} else {
window.addEventListener('GM_AutoPagerizeLoaded',boot,false);
}