What i'd like to do is scrape some data from a page and then open another page in a new tab, and insert the scraped data in a form contained in the new page.
The closest i got to open the new tab is:
function openNewBackgroundTab(){
var a = document.createElement("a");
a.href = "http://www.example.com";
var evt = document.createEvent("MouseEvents");
//the tenth parameter of initMouseEvent sets ctrl key
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
true, false, false, false, 0, null);
a.dispatchEvent(evt);
}
But, as the function name says the tab is opened in the background and it is not focused.
Is there a way to do it in chrome using a js bookmarklet?