1
+ do {
2
+
3
+ if ( ! document . getElementsByClassName ( 'postreply' ) . length )
4
+ break ;
5
+
6
+ var currenttopic = document . location . pathname ;
7
+ var occ = 0 ;
8
+ var ctbegin = 0 ;
9
+ var ctend = 0 ;
10
+ for ( var zix = 0 ; zix < currenttopic . length ; zix ++ )
11
+ {
12
+ if ( currenttopic [ zix ] == '/'
13
+ || currenttopic [ zix ] == '\\' )
14
+ {
15
+ occ ++ ;
16
+ if ( occ == 3 )
17
+ {
18
+ ctbegin = zix + 1 ;
19
+ }
20
+ else if ( occ == 4 )
21
+ {
22
+ ctend = zix ;
23
+ break ;
24
+ }
25
+ }
26
+ }
27
+ if ( ctbegin == 0 || ctend == 0 )
28
+ break ;
29
+ currenttopic = currenttopic . substring ( ctbegin , ctend ) ;
30
+ currenttopic = parseInt ( currenttopic ) ;
31
+ if ( isNaN ( currenttopic ) )
32
+ break ;
33
+
34
+ var x = document . getElementById ( 'CH_PostList' ) ;
35
+ if ( ! x )
36
+ break ;
37
+ var y = x . getElementsByTagName ( 'div' ) ;
38
+ if ( ! y . length )
39
+ break ;
40
+
41
+ var spanlist ;
42
+ var postlist = [ ] ;
43
+ var currItem ;
44
+ for ( var zix = 0 ; currItem = y [ zix ] ; zix ++ )
45
+ {
46
+ if ( ( currItem . id . indexOf ( 'msg' ) == 0 ) &&
47
+ ( ! isNaN ( parseInt ( currItem . id . substr ( 3 ) , 10 ) ) ) )
48
+ {
49
+ spanlist = currItem . getElementsByTagName ( 'span' ) ;
50
+ for ( var ziy = 0 ; ziy < spanlist . length ; ziy ++ )
51
+ {
52
+ if ( ( spanlist [ ziy ] . className == 'dbtn' ) &&
53
+ ( spanlist [ ziy ] . id . indexOf ( 'CH_btn' ) == 0 ) &&
54
+ ( ! isNaN ( parseInt ( spanlist [ ziy ] . id . substr ( 6 ) ) ) )
55
+ )
56
+ {
57
+ var postid = parseInt ( spanlist [ ziy ] . id . substr ( 6 ) ) ;
58
+ if ( isNaN ( postid ) )
59
+ continue ;
60
+ var newspancontent = '<span><a href="javascript:post' ;
61
+ newspancontent += postid ;
62
+ newspancontent += '.quote()" class="C_btn narrow" title="Quote post"><b class="C_ico postreply"></b>Quote</a></span>' ;
63
+ newspancontent += spanlist [ ziy ] . innerHTML ;
64
+ spanlist [ ziy ] . innerHTML = newspancontent ;
65
+ }
66
+ }
67
+ }
68
+ }
69
+ // http://www.cplusplus.com/forum/post.cgi?w=text&p= #ID
70
+ // ---> Formatted text
71
+
72
+ //var fcode = "";
73
+
74
+
75
+ var code = "for_Post.prototype.quote = function(){var result = '';var Network = new XMLHttpRequest();Network.onreadystatechange = function(){if(Network.readyState == 4 && Network.status == 200){result = Network.responseText;}else result = 'error';}; Network.open('GET','http://www.cplusplus.com/forum/post.cgi\?w=text\&p=' + this.postid,false);Network.send();\
76
+ var reply = document.getElementById('CH_reply');\
77
+ reply = reply.getElementsByTagName('a');\
78
+ if(result != 'error')\
79
+ {\
80
+ if(reply[0].href.indexOf('javascript:thread') == 0)\
81
+ {\
82
+ eval(reply[0].href.substr(11)+';');\
83
+ }\
84
+ reply = document.getElementById('CH_reply');\
85
+ reply = reply.getElementsByTagName('textarea');\
86
+ var replier = this.el.innerHTML;\
87
+ var begin = replier.indexOf('<b>');\
88
+ var end = replier.indexOf('</b>');\
89
+ if(begin > 0 && end > 0)\
90
+ replier = '=' + replier.substring(begin+3,end);\
91
+ else\
92
+ replier = '';\
93
+ reply[0].value += '[quote';\
94
+ reply[0].value += replier;\
95
+ reply[0].value += ']'+result+'[/quote]';\
96
+ }}" ;
97
+ var s = document . createElement ( 'script' ) ;
98
+ s . textContent = code ;
99
+ document . documentElement . appendChild ( s ) ;
100
+
101
+ } while ( 0 ) ;
0 commit comments