|
Post by monokr0me on Jul 12, 2012 0:44:52 GMT
This javascript code is not working; console returns no errors.
<script type="javascript">
var tr=document.getElementsByTagName('tr'); for (i=0; i<td.length; i++) { if (tr[i].className.match(/tr_post/i) { sects=tr[i].firstChild.nextSibling.firstChild.firstChild.childNodes() //get to tbody of post body sects.firstChild.firstChild.display='none'; /*var postnum=/^#/i var postnumr=postnum.exec(sects[2]); buts=sects[3].innerHTML sects[3].display='none'; table1=sects[5].getElementsByTagName('table'); sects[4].write(postnumr)*/ } } </script>
Basically, it's to access post content. From what I can infer, it isn't even finding the post. Ignore the commented out part for now.
|
|
|
Post by Fringe Pioneer on Jul 12, 2012 7:43:50 GMT
Alright, let us look at your post in this very page for an example. You can find the relevant code for it from lines 461 to 467, starting from <tr class="tr_post" id="tr_post69317"> to <div class="user_signature"><center><img src="http://dl.dropbox.com/u/20897401/sig.png" alt="[image] " title="[image] " border="0"/></center></div></font></td></tr></table></td></tr>. Assuming your regex match works, which I'm confident it does, the TR element I indicated should be one of the elements of the array of TR elements with the class name of tr_post. The first child of that should be the profile information, and the next sibling of the profile information should be general post information. The first child of the general post information should be a table, and the first child of that should be a TR element. This element extends from <tr><td align="left" valign="middle" width="5%"><img src="http://images.proboards.com/new/xx.png" alt=" " border="0"/> to <a href="javascript:doConfirm('Are you sure you want to delete this post?','/index.cgi?board=programming&action=deletepost&thread=4311&post=69317&page=1',1,1)"><img src="http://i1227.photobucket.com/albums/ee433/GGoodie12/Cobalt/Icons/Message%20Icons/delete.png" alt="[Delete]" title="[Delete]" border="0"/></a></font></td></tr>. After this, you indicate that you want the child nodes of this element; however, if you examine closely, the actual post content is not a child of that element, but a great-grandchild or so of the next sibling of the element. Assuming that tr refers to the overarching post of the class tr_post, then the following will direct you to the actual post content: body = tr[i].firstChild().nextSibling().firstChild().firstChild().nextSibling().firstChild().firstChild().nextSibling()
More specifically, that will give you the FONT element that contains the literal post body. Here is a manually cleaned-up excerpt containing the relevant HTML that would be parsed...
|
|
|
Post by monokr0me on Jul 12, 2012 15:17:18 GMT
However, the post body is not my target; rather, I'm looking for the tables above and below the body, containing post information and resources. My basic goal is to reformat the post title, modification buttons, and the links/IP under the post.
And what confused me is, I used the Chrome Console to hilight the exact areas that I want, so my references should be correct.
|
|
|
Post by Fringe Pioneer on Jul 12, 2012 23:12:35 GMT
Alright, so when you say that it's not even finding the post, do you mean to say that it can't find any of the TR elements of the class tr_post? A null test returns that the array is null despite knowing of the existence of those elements?
|
|