The script I wrote for you was targeting the criteria fields. For what you are asking now, you would need a more general selector.
const selectOption = function (selector, value) {
const selectOpts = document.querySelector(selector)
// if a valid select element
if (selectOpts && selectOpts.matches('select')) {
selectOpts.value = value
selectOpts.dispatchEvent(new Event('change'))
}
}
// explicit selections
selectOption('.riga-contesto select[name="contesto"]', 'tnatm')
selectOption('li[data-field="INDICE"] select[name="canale"]', 'CL')
Final script:
(function() {
'use strict';
const selectOption = function (selector, value) {
const selectOpts = document.querySelector(selector);
// if a valid select element
if (selectOpts?.matches('select')) {
selectOpts.value = value;
selectOpts.dispatchEvent(new Event('change'));
}
}
window.addEventListener('load', function() {
selectOption('.riga-contesto select[name="contesto"]', 'tnatm');
selectOption('li[data-field="INDICE"] select[name="canale"]', 'CL');
});
})();