Unable to input into a textfield?
Hello! I was practicing automation on a website, and found out that I'm unable to input into a input field? I tried all of these:
Last one should be the modern way of doing it, but while it did input it, it did not save it. Anyone knows what is the problem?
39 Replies
Not sure what you mean, and it's hard to help without code. Setting the value should work:
https://codepen.io/jochemm/pen/qBQLPme
That last one (with dispatchEvent) is only really necessary if you want to trigger any event listeners that are listening to the input event on the element
Oh.
Hm, I will try it again tomorrow since I'm not able at the moment
And will try to provide both code and explain it better if it does not work!
I have one question, is the
input
a variable refering to the DOC-element
?
in other words, is it like this:
let input = document.getElementsByTagName("input")[0]
this code means that input
refers to the first input tag in your html
correct me if im wrong but you cant add an attribute to a non-defined elementHere is what I am trying to say
my assumption was that it is set somehow, but yeah, without code it's impossible to tell š
That is true, the information I gave is based on the lack of code provided
I was thinking of what could be the issue, looking at the bits of code he gave
I assume he gave us the things he tried, but nowhere did I see him define the DOC-element he is trying to manipulate
as a side note, btw, it's probably easier nowadays to use
document.querySelector
or document.querySelectorAll
over document.getElementById
or document.getElementsByTagName
Well yeah, there are many ways to call upon elements xd I just gave this one because even if you are a beginner when it comes to coding, this one should be one of the easiest to understand
As you can see the ID in the HTML-element and you can read in the js-code what you aree doing "getElementById"
I don't know his level of coding, so I provided one that even a beginner should be able to follow
Yes of course. My bad for not providing it.
I selected the element with
Input is not my actual variable name, i just used it as an example
I can also select it as
and call it with input[0]
is the class on the element
input
, or are you trying to select an input element with that?could you put your code in codepen or codesandbox? As it would be easier for us to help you if we can play around with your code and see it in full
That up there is the code. xD
wait
Then where is the html code?
Its not my website, I'm doing an automation.
Can;t really provide it.
Does your javascript-file even link to the file you are trying to do the automation on?
you're using ghostmonkey or something?
Tamper š¦
Let me explain it in detail
Once more
then share the userscript in full and the site you're trying to do this on?
When I use
It changes the value visually, but not on their end.
When I submit the form, the default value is submitted.
Input field also has little arrows next to it, and after I input my "input.value = 100;" and click on the arrow to increment it by 1, it changes to default value and increments it by 1, instead of mine.
Only way my value is accepted is if I do any keyboard click afterwards, while that input field is focsued.
So my script is literally
I tried simulating keyboard events, such as keypress, keydown, keyup bot non works. š¦
As I wrote, my "script" is like 2 lines that I provided. xD
they might be storing the value some other way, there is no way to tell without seeing the whole site
are there data attributes on the input?
what event handlers are bound to the input when you inspect it?
Here
check the rest of the source of the website for calls to
fetch
Sec
It has an event as well I think
also, what are you trying to automate?
It's a form. I'm automatically adding info, and submiting it.
that sounds pretty shady tbh
xD
Ofc, I'm not 100% honest, but I can't really provide everything. But it literally is a form with that script. It is not malicious as well! it is a gambling website, and I'm trying to ease my input with this script.
yeah, I'm not comfortable helping with that
Check my post history here, I'm doing this as practice.
With non-existent benefit, I just wanted to automate the procces instead of clicking. That is it
But as saying "gambling website" will give that reaction.
Either way, I still want to use this discord as my own means of practice, sicne it helped my a lot, so I will delete this post if it markes me as a scammer or fishy person.
But I only did asked because I did not understand why such a simple thing does not work, not to scam someone. Pure practice.
don't worry about it, I'm just personally not comfortable messing with gambling sites
Roger. My apologies for being a round-about about this whole thing!
honestly, if you're doing this for practice, I'd suggest picking a different site simply because a gambling site is going to have stuff in place to prevent exactly this thing
Yeah. I tought so. xD It must be some kind of antichear thing. But I do not see the benefit, I'm just prebetting, that is why I did not understand it? Maybe because of bots?
they're doing something funky on submit if setting
.value
isn't working. You'd have to read the code that does the submitting (which you could find by searching for the submit event handler on the form, or the click handler on the button, or by looking for fetch
or FormData
in the code)
probably bots yeah, or just a general anticheat measure they implemented site-wide even for bits where it isn't necessaryBut it accept the value when I trigger keyboard event, before submit. So yeah, it must be to ensure it is type by hand and not like this.
I just did not know it was possible.
could be they're listening to keypress instead of keydown
It is a 2 step, input and submit, it does not change it for me, But it was driving me crazy I will admit. xD
I tried both, maybe I wrote it wrong?
Either way, yeah, it must be something much more complicated. It was pure curiosity that was driving me nuts, since I did manage to do it on 1 other betting website, but this one did not budge. xD
I will not bother you anymore, my apologies.
But I swear it was pure curiosity! Not to scam or anythinh, like implementinh my knowledge irl for the firstr time. xD
anything* implementing*
's all good, no worries
Cheers! And thanks. Pretty sure you helped me more than few times before, I recognize your name!
š«”