T
T
The_Immortal2021-01-15 02:14:50
JavaScript
The_Immortal, 2021-01-15 02:14:50

Radiobutton selection script and button click?

I'm trying to write a Greasemonkey script that should set true for a specific radiobutton and then click on a specific button (although it's the only one on the page). After a successful operation, another page opens, after which you need to return to the previous one and repeat everything again (select the desired "radio" and click on the button) - i.e. arrange a cycle.

I have not yet reached the return to the previous page and the cycle, because corny I can not select "radio" and click on the button.

<input type="radio" name="thisradio" value="123">
<input type="submit" onclick="send(); return false;" value="Запустить">


My attempts:
// ==UserScript==
// @name     Скрипт БезИмени 648414
// @version  1
// @grant       GM_openInTab
// @grant       unsafeWindow
// @run-at      document-start
// ==/UserScript==

document.querySelector('[name="thisradio"][value="123"]').checked = true;
document.querySelector('[value="Запустить"]').dispatchEvent(new MouseEvent('click'));

In the console, this code seems to work, but the script itself does not want to work. Tell me, please, what could be wrong?

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2021-01-15
@HistoryART

Pass an element whose checked property will be changed:

waitForKeyElements ("input[name='thisradio'][value='123']", selectRadioButton(/* сюда передайте */), true);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question