so like you guys said i removed the Pcontains thing because there is
no <p>
and when i first tried he nagged about the return again so i removed
it and therefore ended up with :

var ew=document.evaluate("//strong",document,null,
9,null).singleNodeValue;

ew=ew.innerHTML*1;

alert("Number of earthworms is "+ew);

and when i ran this i finally got output... namely my fishing fever
score (wich is a different number in <strong> a little before the one
i need. (actually the one right before it.

so how can i make him skip the first one and use the second one he
finds.

PS: i allready want to thank all of you for helping me here :p i know
i'm not the most experienced scripter but its nice that others help
you sometimes :p

friendly greets

On 24 okt, 20:46, cc <[email protected]> wrote:
> The return only works if the chunk of code is within a function. If
> you're using a current version of Greasemonkey, it should just work
> (because most versions wrap the script in an anonymous function before
> executing).
>
> Alternatively, reverse the logic of the if statement and put the two
> following statements inside the if block, getting rid of the return
> statement entirely.
>
> Gordon already touched on the real problem with this code, of course,
> which is that the XPath is looking for <p> tags that don't exist.
>
> On 2009-10-24 05:48, Stuer Michael wrote:
>
> > Well i just tried the piece of code erik posted but i got some errors
>
> > i tried the script as follows
>
> > var ew = document.evaluate("//p[contains(.,'earthworms')]/
> > strong",document,null,9,null).singleNodeValue;
>
> > if(!ew) return; // no earthworms node found
>
> > ew = ew.innerHTML*1;
>
> > alert("Number of earthworms is "+ew);
>
> > but i got this error: SyntaxError: return not in function
> >   in eval() line 0
>
> > and then i tried withouth the return line and got this:
>
> > TypeError: ew is null
>
> > maybe it'll help if i post more of the source page.
>
> > <table id="megaTable2" cellpadding="0" cellspacing="0">
> >    <tr>
> >            <td rowspan="2" id="leftSpacing">
> >            </td>
> >            <td id="contentBox" height="500" valign="top">
> >                    <center>  <table border="0" cellspacing="0" 
> > cellpadding="2"
> > width="100%">
>
> >            <tr>
> >                    <td width=95% class="heading_box">
> >                            Fishing Fever
> >                    </td>
> >            </tr>
> >    </table><br>Here in the lake district, we offer you the chance to
> > compete in our famous fishing fever competition. All you need is an
> > earthworm to use as bait, and a good sense of where in the lake you'll
> > find the largest catch.<br><br>Your current fishing fever score is
> > <strong>31</strong><br><br>You currently have<strong>98</strong>
> > earthworms. Earn more at<a href='dirtdigger.php'>Dirt Digger</
> > a><br><br>Pick a location, cast your line, and see what you reel in!
> > <br><br><form method='post' action='/fishingfever.php?act=fish'><input
> > type='image' src='http://www.pokeplushies.com/images/games/
> > cf_lake.jpg' style='cursor:crosshair;'><input type='hidden'
> > name='code' value='74848'></form><br><br><a href='/fishingfever.php?
> > act=topfishers'>Click here to see who the top fishers are!</a>              
> >       </
> > center>
>
> >            </td>
> >            <td rowspan="2" width="160" valign="top">
> >                    <center>
>
> > On Oct 23, 8:30 pm, Erik Vold<[email protected]>  wrote:
>
> >>   A regex will work, but xpath expression is better in general, or you
> >> could write an xpath expression with some 
> >> regexhttp://www.regular-expressions.info/xpath.html
> >> which is probably better if you are going to use regex at all.
>
> >> Using Gordon's xpath exp the js to get your earthworm count should be
> >> like:
> >> var ew=document.evaluate("//p[contains(.,'earthworms')]/
> >> strong",document,null,9,null).singleNodeValue;
> >> if(!ew) return;// no earthworms node found
> >> ew=ew.innerHTML*1;
> >> alert("Number of earthworms is "+ew);
>
> >> Where the last line that alerts the earthworm count is something more
> >> useful.
>
> >> Erik
>
> >> On Oct 23, 6:36 am, Gordon Pettey<[email protected]>  wrote:
>
> >>> On Fri, Oct 23, 2009 at 4:33 AM, 杨大成<[email protected]>  wrote:
>
> >>>> i don't see any js can operate<strong>  ,
> >>>> how about regex?
>
> >>> I repeat: XPath. No need for a regex.
>
> > ____________________________________________________________________________________
> > Introducing Branchr
> > Super Simple Advertising
> >http://click.lavabit.com/?pub=78&ad=0023&url=aHR0cDovL2JyYW5jaHIuY29t...
> > ____________________________________________________________________________________
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to