Tampermonkey script that autoselects an item with a specific value in a dropdown menu:
(function() {
'use strict';
const dropdown = document.querySelector('#myDropdown');
dropdown.value = 'item2';
})();
This script selects the element with the ID
myDropdown
and sets its value to
item2
. You can modify the script to select a different item by changing the value of the
dropdown.value
assignment.
To use this script, install Tampermonkey and create a new script. Paste the code into the script editor and save it. The script will run on pages that match the URL pattern specified in the
@match
directive (in this case,
https://example.com/*
).