0

I don't know that much about javascript yet, but I know you can open and close a webpage with this:

var myWindow = window.open('whateverpage.com'); myWindow.close();

but say you wanted to actually do something on that page you opened, like filling out a form, is there a way to do that? Something like:

myWindow.getElementById('input').value = 'hello';

Edit: the reason I'm wondering is that I want to make an autologin page (for personal use so I can go through school stuff a little bit faster). So all I need to do is make a webpage that changes the values of inputs on another webpage and then submits that form.

NitroFray
  • 43
  • 7
  • 2
    Yes from the same origin but not from another origin - did you try? And keep the console open when you do – mplungjan Dec 12 '18 at 18:34
  • https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy – Thomas Dec 12 '18 at 18:35
  • It says: "Uncaught TypeError: myWindow.getElementById is not a function" – NitroFray Dec 12 '18 at 18:36
  • try `window.get...` – Caleb Jay Dec 12 '18 at 18:37
  • To note Thomas' comment - you couldn't actually *send data* to their server. You could do literally anything you want to a given webpage, but nothing you could possibly do would affect other users (using this method). That being said, you could simply navigate your browser to that url you passed into `window.open()` and start messing around there in the console :) (don't break the law) – Caleb Jay Dec 12 '18 at 18:39
  • I recommend looking into bookmarklets, they can be really handy for this kinds of stuff – Sebastian Speitel Dec 12 '18 at 18:44
  • I've used the Chromium browser to do this kind of thing, specifically in my case by using C# and the cefsharp browser. You can remotely run javascript and receive responses, it's quite swanky. Can write all kinds of naughty things! Tut Tut :P https://stackoverflow.com/questions/31155779/cefsharp-execute-javascript – Dan Rayson Dec 12 '18 at 18:54
  • You cannot access anything from anywhere if you close the window before accessing it. So `var myWindow = window.open('whateverpage.html'); myWindow.document.getElementById("something").innerHTML="Hello";` ` You may need setTimeout to allow the window to load the page first – mplungjan Dec 12 '18 at 21:26
  • I get this: "Blocked a frame with origin "null" from accessing a cross-origin frame." when I do it. But I'm testing with two files that are both on my computer. Shouldn't it work then?? – NitroFray Dec 12 '18 at 21:59

1 Answers1

-1

You could use Greasemonkey, Tampermonkey, Scriptish or similar
to manipulating the current page (fill formulars)
These tools are injecting (your) java script into the current web page.

https://de.wikipedia.org/wiki/Greasemonkey

Kux
  • 1,362
  • 1
  • 16
  • 31