Getting node using document.getElementsByClassName

486 views
Skip to first unread message

Gids

unread,
Nov 24, 2009, 6:58:17 AM11/24/09
to greasemonkey-users
Hi,

I am writing a greasemonkey script to insert extra content into
radiotimes.com TV listings like this example:
http://www.radiotimes.com/ListingsServlet?event=10&channelId=92&programmeId=106592517&jspLocation=/jsp/prog_details_fullpage.jsp

However, I am having a problem returning a node which I want to
InsertBefore using getElementsByClassName

Here's what I am doing at the moment:
var summary = document.getElementsByClassName('summary');
var Thissummary = (summary[0]);

This returns: [object XPCNativeWrapper [object HTMLHeadingElement]]

Then later on I call:
document.body.insertBefore(logo, Thissummary);
however, this fails with 'Node was not found'

How can I change my script to return a node, or is there a better way
altogether to do this?

Thanks in advance,

Gids

RodMcguire

unread,
Nov 24, 2009, 8:54:29 AM11/24/09
to greasemonkey-users
WRONG:
document.body.insertBefore(logo, Thissummary);

RIGHT:
Thissummary.parentNode.insertBefore(logo, Thissummary);

On Nov 24, 6:58 am, Gids <gidsgoldb...@gmail.com> wrote:
> Hi,
>
> I am writing a greasemonkey script to insert extra content into
> radiotimes.com TV listings like this example:http://www.radiotimes.com/ListingsServlet?event=10&channelId=92&progr...

Gids Goldberg

unread,
Nov 24, 2009, 10:35:46 AM11/24/09
to greasemon...@googlegroups.com
Thanks, that did the trick!

2009/11/24 RodMcguire <gibbon...@yahoo.com>:
> --
>
> You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
> To post to this group, send email to greasemon...@googlegroups.com.
> To unsubscribe from this group, send email to greasemonkey-us...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
>
>
>
Reply all
Reply to author
Forward
0 new messages