I made a simple script to run in my android chrome. It comes that there are 2 scenarios working differently:
first one javascript:(alert("try")) works with no problems
second one javascript:(async function test(){alert("try")};test()) does NOT work
obv it's not what i am trying to do but in my desired script i need an await or a generic sleep. What can i do?
edit: the curious thing is that setInterval works fine... but javascript:(let prova = "try";alert(prova)) doesn't work
edit2: i did it, it took a very bad headache but now works. There are things that doesn't work for some reason but a workaround can always be found
here's what's the final working version
javascript:(setInterval(() =>{setTimeout(() => {document.querySelector('.nameofthetextareaselector').value="value i wanted to put here";document.querySelector('.nameofthebuttontosend').click();new Promise(resolve => setTimeout(() => {document.querySelector('.nameofthesecondbutton').click()},2000));resolve},2000)},5000))
It edits the textarea, send it, click another button after some seconds and repeat
things that not worked: assign anything with let, const or directly the name of the variable, nesting promises, using async-await, using try-catch, etc...
Now i am happy that all works but i want to know why all these things doesn't seem to work (only on android chrome, on windows chrome all these things worked)
What you are doing right now is just declaring a function without calling it, you can add () at the end of javascript function to execute it right away.
javascript:(async function test(){alert("try")}())