I'm writing a Tampermonkey code for a webpage like ConverTo:
It's supposed to automatically select the second option in a dropdown:
<select class="format-select">
<option value="mp3">MP3</option>
<option value="mp4">MP4 (video)</option>
</select>
, several seconds after the page is fully loaded.
But nothing happens.
My code:
......
// @match https://www.converto.io/*
// @require http://code.jquery.com/jquery-1.11.0.min.js
// ==/UserScript==
$(document).ready(function(){
setTimout(test(),10000);
function test()
{
$(".format-select").val('mp4');
}
})();
Please help!
See Choosing and activating the right controls on an AJAX-driven site.
Many AJAX-driven controls cannot just be changed; they also must receive key events, for the page to set the desired state.
In the ConverTo case, that select appears to expect‡ :
You would send that sequence with code like this complete, working script:
‡ There are other state sequences possible, to the same end.