I can't perform a search query in google via javascript in tampermonkey

I am trying to implement an automatic search query in google ( or other search engines) via javascript in tampermonkey. I managed to assign a value to the search string ( input) and everything seemed to go according to plan, but at one point I realized that despite the presence of any text in imput, the search engine itself does not perceive it in any way. However, if after typing through.value = "text" or any other way to enter information hover the mouse over the object imput and to enter any sign yourself, the search engine begins to understand the entered text, but it is not an option to click yourself, because we need automation. I tried simulating a keystroke via jQuery namely using .keypress(), but it didn't work out. I tried many other options, such as entering text after focusing on an element using jQuery

  $( '#pole_vvoda' ).on({
    'focus': function() {
        $( this ).val("Мой запрос");

    }, 

But this did not give success. Please help with the problem and, if possible, write the code that will execute a search query, for example, in Google. Thanks.

Author: 2ip, 2020-04-11

1 answers

I tried with gogol, in this extension

$('.gLFyf.gsfi').val('asd');
$('input.gNO89b').click();

(I don't know when these selectors will be updated, but) it worked for me

Secondly, tampermonkey (as for me) is suitable for the tasks of the plan: [1.] вкинул код [2.] забыл ([3. обновил]), because it is not user\dev friendly. And if you want to distribute your code, then look already in the line of extensions, there is not such a dark forest..

Therefore, here is the extension, for критикуешь(tm) - предлагай, try the following code in it, just do not forget the fresh jq connect and select it from the site script (by hover on the options, above the editor, screen below)

window.onload=()=>{
    $('.gLFyf.gsfi').val('asd');
    $('input.gNO89b').click();
};

It should look like this: extension screen

 1
Author: Vadim, 2020-04-12 07:24:17