[greasemonkey-users] Copy information from a tab to another with greasemonkey

97 views
Skip to first unread message

gandahar

unread,
Aug 9, 2012, 8:09:03 PM8/9/12
to greasemon...@googlegroups.com

Hi!

I would like to write a very simple greasemonkey script, for educational
purpose:
Let's say I have a html file on my local computer, which contains a form
(f1) and a textarea in it, named t1. I type some letters in it. Then I open
a webpage in a new tab, which also contains a form (f2) and a textarea,
named t2. How can I copy the content of the textarea t1 into the textarea
t2?
--
View this message in context: http://old.nabble.com/Copy-information-from-a-tab-to-another-with-greasemonkey-tp34279794p34279794.html
Sent from the GreaseMonkey List mailing list archive at Nabble.com.

Matt Sargent

unread,
Aug 10, 2012, 2:18:28 AM8/10/12
to greasemon...@googlegroups.com
Save it to local storage, which any open tabs will have access to, as
long as they are open in the same domain as the original.

mike cupcake

unread,
Aug 13, 2012, 5:58:50 AM8/13/12
to greasemon...@googlegroups.com, kisb...@gmail.com
On Friday, 10 August 2012 01:09:03 UTC+1, gandahar wrote:

Let's say I have a html file on my local computer, which contains a form
(f1) and a textarea in it, named t1. I type some letters in it. Then I open
a webpage in a new tab, which also contains a form (f2) and a textarea,
named t2. How can I copy the content of the textarea t1 into the textarea
t2?

Have the script run on both pages.  Code page1 to open the URL for page2 + the information in a query string,  make page2 read the string and put it into the boxes.

e.g.
http://server.com/page2.htm?mytext=hello

You can use use URIEncodeComponent()  to handle special characters/spaces/etc.

mike cupcake

unread,
Aug 13, 2012, 7:48:40 AM8/13/12
to greasemon...@googlegroups.com, kisb...@gmail.com
On Monday, 13 August 2012 10:58:50 UTC+1, mike cupcake wrote:
You can use use URIEncodeComponent()  to handle special characters/spaces/etc.

correction:  encodeURIComponent()

Matt Sargent

unread,
Aug 13, 2012, 12:43:51 PM8/13/12
to greasemon...@googlegroups.com
The advantage to using Local Storage is that the copy can work in real time. You can break out one of the tabs into a separate window, so you can see both entry boxes at the same time. Type in the box on the source window, and the text can appear as you type it in the target window. All that would take is an event listener for changes to the input box, and on the target side, an event listener for local storage change, to update the second text box.
--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/greasemonkey-users/-/l5JTlG9b6HcJ.
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