Skip to content
Advertisement

Tampermonkey automation of selecting option in a menu

I’m trying to write a script for selecting an option from a menu once the website is loaded. Here is the code of the menu.

JavaScript

I have tried several codes from StackOverflow. Like

JavaScript

and

JavaScript

Both of them work in the Console of Google Chrome. However, it does not work when I copy and paste the script in tampermonkey. Does anyone have any idea about this problem?

Edited

Here is the full script.

JavaScript

Advertisement

Answer

Try this:

JavaScript

Perhaps the JavaScript is running before those elements have been created on the page…? The suggested code waits 1.5 seconds before trying to change the value. If that works, change the 1500 to 300 or 500 or ?.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement