views:

31

answers:

1

Hello,

I got two different forms in two different tabs. One has data from our system and the other one is an interface of another, external, system in wich we need to copy data into (XML or API integration not an option here)

The this is that, having open both forms - in two different tabs - i need a greasemonkey script or something similar that allows my to copy data from one form to the other (using the getValue method in Javascript).

The problem right now is that I cannot figure out how to reference with a greasemonkey script one particular tab or window (to rad data from or write data to). Do you think it would be possible to do what I'm thinking to do?

THANKS

+1  A: 

Yes, I believe it's possible. Greasemonkey stored configuration values are stored per script so you need to make sure that your single Greasemonkey script runs against both of those pages, even if they're at different URLs. (More info here.)

You're probably going to want a large if/else block to divide up the code you want to run on the source page and on the target page, with something like this:

if (window.location.hostname.match(/source-site\.com/) {
    //attach to the form fields and make them call GM_setValue() on every change
} else if (window.location.hostname.match(/target-site\.com/) {
    //use GM_getValue() to pull in the data you stored from the source site
}

This seems easier than having the script execute on one page and try to access the DOM of other open windows (which I'm not sure is possible).

npdoty