0
var gmaill = window.open("https://mail.google.com/mail/u/0/#sent", "_blank");
setTimeout(function() {
alert(gmaill.document.getElementById(":113").innerHTML == "Test");
}, 3000);

I am using setInterval to look at a website, and when a condition is met, I am opening a different tab to gmail and sending an email. Unfortunately, I cannot access different tabs that are on different websites through Chrome's console (i.e. I run it from twitter to wait for a tweet and open a new tab for gmail and email someone the link to the tweet). It either doesn't return anything, or there is a security error. Is there any way to get around this? Could I make an extension and have it get around it?

1 Answers1

1

What you are attempting is called Cross site scripting. Your caller is in one domain and actual script is in other. For security reasons most of the browsers follow same origin policy. Meaning to access script or DOM in other window both the windows must be on same domain.

https://en.wikipedia.org/wiki/Same-origin_policy

https://en.wikipedia.org/wiki/Cross-site_scripting

I have tried it earlier. Programmatically it is impossible to do. Not sure if you can achieve using some kind of hacking at browser level

Dattatreya Kugve
  • 320
  • 1
  • 4
  • 21
  • However if you have control over the sites where cross domain scripting is required then you can actually achieve it. Check the below link http://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work . But unfortunately in your case sites are Gmail and Twitter which you don't have control . So you can't do it – Dattatreya Kugve Sep 15 '15 at 07:28