JS greasemonkey输入文本框
我是新手JS程序员,只是试图在这里和那里进行一些自动化,并使用GreasemonKey/Tampermonkey/firevermonkey等扩展名进行自动化。 我碰到了我找不到解决方案的墙,已经试图搜索几天,但仍然无法弄清楚。
问题是:有页面按钮(例如书),它可以返回,向前并设置一个数字以跳到x该页面。 我可以毫无问题地点击背部和前进。我唯一的问题是利用输入框(不确定是否称呼它)。
该框是这样的工作:您将内部设置任何数字并按Enter(确认/提交值更改的唯一方法),如果页面存在,则将跳到该页面。 对我来说一件奇怪的事情是,我尝试手动将其从1(默认)更改为3,它们设置为脚本上的2(带有X.Value),当我手动确认它时,它将转到第3页,而不是第2页(甚至虽然它在UI上显示2,也显示了.value)。因此,我至少至少得到了我得到的价值,但似乎我无法做到。
另外,将DevTools上的值=“ 1”更改为其他任何内容都不会更改UI,也不会注册输入更改,因为当我按Enter Enter时,请忽略我的值。
这是输入框的DevTools上显示的HTML:
<input class="number" value="1" style="width: 40px; height: 40px; text-align: center;">
我不使用jQuery(仅仅是因为我不知道如何使用它),但是如果有必要,我可以学习!
console.log,还有一些有关我可以在线搜索的元素的信息
我不知道我能提供的其他任何东西可以帮助进一步的帮助。 如果有什么,请告诉我,并感谢您的帮助!
I'm a newbie JS programmer, just trying to do some automation here and there with extensions like Greasemonkey/Tampermonkey/Violentmonkey.
I ran into a wall that I can't find a solution, already tried to search for it for days and still can't figure it out.
The problem is this: there's page buttons (like a book), it can to go back, forward, and set a number to skip to X that page.
I can click on both back and forward with no problem. My only issue is making use of the input box (not sure if that's how it's called).
The box works like this: you set any number inside and press ENTER (only way to confirm/submit the value change) and them it'll skip to that page if the page exists.
One weird thing for me is that I tried changing it manually from 1 (default) to 3, them setting to 2 on script (with x.value) and when I confirm it manually, it goes to page 3 and not page 2 (even though it's showing 2 on UI and also on .value). So I though at least the value set I got, but it seems that even that I couldn't make.
Also changing the value="1" on DevTools to anything else doesn't change the UI and also don't register the input change, since when I press enter it just ignore my value.
This is the HTML shown on DevTools of the input box:
<input class="number" value="1" style="width: 40px; height: 40px; text-align: center;">
I'm not using jQuery (simply because I don't know how to use it), but if it's necessary I can learn!
Screen of the HTML structure on DevTools
Console.log with some info about the element I could search online
I don't know anything else I could provide to help further assistance.
If there's anything, please let me know and thank you for helping!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 @Woxxom的解决方案,我可以做到!
它需要的只是他的解决方案(请参阅注释),以更改文本框的内部值,并且它们是El.dispatchevent,其中Enter On On On键使提交工作!
With @wOxxOm's solution I was able to do it!
All it needed was his solution (see comments) to change the inside value of the textbox and them a el.dispatchEvent with enter on it's key made the submit work!