PDA

View Full Version : Simple hack to inject javascript to first post in thread?


ahains
01-30-2007, 09:39 PM
I have a script block I want to include in the textual body of the first post of a thread. Actually I may want the first post of page N of a thread, so the same script gets injected to the first post on each page of the thread.

I have read and understand a hack for repeating the first post on every page of the thread, so I understand in general where to hook in.

What I don't understand is how to manipulate the body of that first post.

If I do something like

if ($post['postid'] == $thread['firstpostid'])
{
$post['pagetext'] = 'My Script Goes Here' . $post['pagetext'];
}


Then I get my text injected into the post body. However the actual script code doesn't execute because I need a newline in there, and the encoding to html causes this to become a BR tag which foob's up the script.

This makes me thing I should be mucking with $post['pagetext_html'], but if I try to append to that value then ALL I get in the post body is my script text. Obviously I'm doing something wrong.

Any tip on if pagetext_html is in fact what I should be touching, and what hook I can safely modify its value in?

Thanks!
-Adrian the newbie