[Greasemonkey] Bug: User script doesn't always execute in GM 0.5

Josh Matthews mrlachatte at gmail.com
Sun Aug 7 15:19:47 EDT 2005


It looks like you're using named forms in your scripts, and IIRC
that's not allowed in GM 0.5.  I'd find a reference for you, but I'm
running out the door; hopefully someone else can confirm/deny.

Josh

On 8/7/05, John Plsek <gm at plsek.id.au> wrote:
> Michael Kraft wrote:
> 
> >I'm using Firefox 1.0.6 under Windows XP SP2.
> >
> >I wrote a script that will keep clicking on a button or a link depending on
> >which is on the page at the time.  I use it to automate playing
> >KingdomOfLoathing.  The script works great in GM 0.3.5, but haphazzardly in GM
> >0.5.  In 0.5 sometimes it works and sometimes it does not.
> >
> >The strange thing is if I put in an alert() call to spit out something at the
> >beginning of the script that won't even execute even though the script is set
> >to execute on that page.  Yet if I put the same alert() call at the end of the
> >script not only will the alert popup, but the script will execute correctly
> >every single time.
> >
> >Any ideas why this is happening?
> >
> >Here is the script:
> >
> >// ==UserScript==
> >// @name           Kingdom of Loathing auto adventure
> >// @namespace      http://mywebsite.com/myscripts
> >// @description    Automatically repeats adventuring in Kingdom of Loathing
> >// @include        http://*.kingdomofloathing.com/fight.php
> >// @include        http://*.kingdomofloathing.com/adventure.php
> >// ==/UserScript==
> >
> >(function() {
> >   if (typeof(document.attack) != 'undefined')
> >      document.attack.submit();
> >   else {
> >      var xpath = '//a/text()[contains(., "Adventure again")]/..';
> >      var theLink = document.evaluate(xpath, document, null,
> >                    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
> >      linkElement = theLink.snapshotItem(0);
> >      if (linkElement != null) {
> >         actualMessage = linkElement.getAttribute("href");
> >         document.location = actualMessage;
> >      }
> >   }
> >})();
> >
> >_______________________________________________
> >Greasemonkey mailing list
> >Greasemonkey at mozdev.org
> >http://mozdev.org/mailman/listinfo/greasemonkey
> >
> >
> >
> >
> Correct me if I'm wrong, but couldn't you achieve the same result for
> the document.evaluate by
> 
> var xpath='//a[contains(text(), "Adventure again")]';
> var theLink=document.evaluate(xpath, document, null,
> XPathResult.SINGLE_UNORDERED_NODE_TYPE, null);
> var linkElement=theLink.singleNodeValue;
> 
> however, I can't help with the problem, sorry - I didn't think "alert"
> worked at all in GM!
> 
> John
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>


More information about the Greasemonkey mailing list