1

There is a website I have to access frequently which puts strings to a stack. There are two inputs on the browswer that have a default value, so the page opens with them filled out.

I have two commands which replaces the values in both of these to the inputs I'd like:

document.getElementsByName("input1")[0].value = "input1";
document.getElementsByName("input2")[0].value = "input2";

if I run this in the chrome browser console it works just fine, and I can click the up arrow to pull this up again next time I sent a string which is useful. However, I'd like to be able to save those two lines as a file on my local machine, so I can just run the file name once instead of having to copy the two lines for whichever inputs I want:

For example, instead of having to copy the above 2 lines at the beginning of my testing, I could just type in setInputs.js.

And for other inputs, I would have other files, so I could type in setInputsVersion2, 3, 4... etc. as I need to.

Is this possible?

j08691
  • 204,283
  • 31
  • 260
  • 272
Jack_Frost
  • 169
  • 2
  • 8
  • 2
    A browser extension like [Tampermonkey](https://www.tampermonkey.net/) can be useful –  May 08 '20 at 17:19
  • Something similar has already been answered here. https://stackoverflow.com/questions/9731965/is-there-a-way-to-create-and-run-javascript-in-chrome – Xth May 08 '20 at 17:21
  • https://developers.google.com/web/tools/chrome-devtools/javascript/snippets – epascarello May 08 '20 at 17:27

1 Answers1

2

You may want to look at using "tampermonkey" or "greasemonkey". you can define what website to run javascript code on and at what time etc. You can run the javascript code on the domain and then type the function into the JVM (javascript console) onto chrome to save you time as well.

zatamine
  • 3,458
  • 3
  • 25
  • 33