> Is there anyway to do this or is it just not possible?

You can probably use a 'custom event' to send simple data from code
that runs on the user page to code running in the Greasemonkey
sandboxed script.

e.g. Code in userspace does something like (say domNode is a node you
want to send the event on)

 var ev = document.createEvent('Events');
 ev.initEvent('mycustomevent', null, null);
 ev.myData1 = data1;
 ev.myData2 = data2;
 domNode.dispatchEvent(ev);

Then in a greasemonkey script you do something like

 domNode.addEventListener('mycustomevent', customEHandler, true);

 function customEHandler (e) {
  var target = e.target;
  var data1 = e.wrappedJSObject.myData1;
  var data2 = e.wrappedJSObject.myData2;
  ... do stuff ...
 }

XPC native wrapper doesn't automatically propagate custom event
properties so you have to unwrap things explicitly, and as I recall
the above should work correctly for your case.

If you are creating custom events in a greasemonkey
script, .createEvent returns a wrapped event which means means if you
want to attach data to it, it has to be done on the unwrapped event.
E.g.

  ev.wrappedJSObject.myData1  = data1;

On Feb 25, 11:44 am, rveach <[email protected]> wrote:
> On Feb 25, 11:02 am, Anthony Lieuallen <[email protected]> wrote:
>
> > You really shouldn't be interacting with unsafeWindow at all, you should
> > be addEventListener'ing the form element.
>
> >http://wiki.greasespot.net/Avoid_Common_Pitfalls_in_Greasemonkey
>
> Thanks for replying.
> I figured it was my fault somehow. :)
>
> The addEventListener on the form isn't firing
> ("forms[i].addEventListener('submit', newFormSubmit, false);"), I
> assume it is because the page is using javascript links to submit the
> form "javascript:document.search1.submit();"?
> I could add onclicks to the javascript links, but I also wanted to
> capture submit events even if the user is using another GM script to
> submit the form using code like:
> "document.forms.namedItem("search1").wrappedJSObject.submit();".
>
> Is there anyway to do this or is it just not possible?

-- 
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