Reputation: 26089
I am executing scripts using Chrome Developer Tools console on two websites. On first website script gathers data, and on the second website another script takes these data, and puts it in a form.
Websites use different domains. Currently I am manually copying result from script one, and paste it into script two as a input data. But this takes too much time.
How to pass data from console of first website to console of second website programatically knowing they are NOT same origin?
Upvotes: 1
Views: 129
Reputation: 370599
I'd recommend using a userscript instead. Set the userscript to run on both pages, and use GM.setValue
to save the data on the first page, then use GM.getValue
to retrieve the data on the second page. For example:
// ==UserScript==
// @name New Userscript
// @include /^https://stackoverflow.com/
// @include /^https://example.com/
// @grant GM.setValue
// @grant GM.getValue
// ==/UserScript==
if (window.location.host === 'stackoverflow.com') {
GM.setValue('data', 'foo'); // .catch the Promise here if you want
// after the data is saved, you could also redirect automatically if you want:
// window.location.href = 'example.com'
} else {
GM.getValue('data')
.then((result) => {
console.log(result);
});
// .catch the Promise here if you want
}
Result, after going to Stack Overflow and then to example.com:
You'll need a userscript manager like Tampermonkey.
No more copying-and-pasting necessary - just write the userscript code once to automatically scrape, save, and possibly redirect to the new page and populate it as well.
Upvotes: 1