I want to grab some data from a page opened in one tab, and paste it into a textarea of another page opened in another browser tab. How can I do this with Javascript and Greasemonkey?
GM_setValue
in the store. If needed, open the next website by using GM_openInTab
.GM_getValue
and paste it into the textarea.Not this hard over Greasemonkey, even though its necessary to load the textarea-page AFTER the table-page.
Example
// @include http://website1.com/*
// @include http://website2.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
$(document).ready(function() {
if( $("#divfromsite1").length )
{
GM_setValue("pastetext", $("#gettable").html() );
GM_openInTab("http://website2.com/");
}
else
{
$("#pastetextarea").val( GM_getValue("pastetext","") );
}
});