1

I want to create a script in JS which would allow me to open (probably many) new windows to external sites (e.g. facebook) and autocomplete login and password (eventually - just login) with given creditentials.

Note: I don't care about security, it's just an inner-use script.

Basing on W3S I made something like:

<html>
<head>
    <title></title>
</head>
<body>
<script src="open.js">
</script> 
</body>
</html>

and:

var fb = window.open('https://facebook.com');
if(fb) {
    fb.onload = function() {
        fb.document.getElementById('email').value = 'what';
        fb.document.getElementById('pass').value = 'ever';
        fb.document.getElementById('loginbutton').click();
    }
} else {
    alert('Please allow popups for this website');
}

But all these do is open given site in a new tab.

I'm completely new to JS and HTML, so please explain like I'm five.

edit: Ok, I've learnt thet it's impossible to set external domain's values using only JS and HTML (correct me if I'm wrong). Is there any quick way (code snippet would be most appreciated) to do so? I found some info and made a user's extension to chrome (not working so don't bother pasting the code), yet still have no idea how to implement this to many new windows or generally - how tf should I do this... Any help, please?

Canert
  • 23
  • 6
  • 3
    Javascript cannot be executed across domains -- since your host is not facebook.com, it is blocked from getting elements from facebook's DOM – Will P. May 30 '17 at 21:58
  • Possible duplicate of [Changing popup content](https://stackoverflow.com/questions/7396478/changing-popup-content) –  May 30 '17 at 22:02
  • @WillP. So is it impossible then? – Canert May 30 '17 at 23:17
  • @TyQ. I think not - as mentioned, I'm about to set values of an external site's forms. – Canert May 30 '17 at 23:18
  • In the end, you're still changing popup window content as suggested in the title. –  May 30 '17 at 23:32
  • @Canert Unless the site you're trying to modify has some kind of `window.postMessage` API, it is probably not possible unless you use something like a greasemonkey/tampermonkey script to expose a `window.postMessage` API. This would essentially be a 3rd party script your site's users would have to install, so probably not an ideal solution. – Will P. May 31 '17 at 18:57

1 Answers1

0

More detail window.open here https://developer.mozilla.org/en-US/docs/Web/API/Window/open

It is better to use http://docs.toddish.co.uk/popup/demos/ or another libs