Scriptable webview not playing sound on specific website

I’m using Scriptable to get a Siri shortcut which loads a radio news website and uses evaluateJavaScript to press the play button, which will have the effect of playing the latest news whenever I launch the shortcut.

Although it looks like the button gets pressed as expected, no sounds play on the iphone. I’ve tested this site using Safari on the phone and it plays as expected. I’m sure I’m missing something, but I don’t know what. Here’s my code:

let url = “
let wv = new WebView()
await wv.loadURL(url)
let js = ‘document.querySelector(\’#play_last\’).click();’
wv.evaluateJavaScript(js, false)
await wv.present()

Thanks for any help you can give!

Did you copy the source directly from your script into your post here? If yes, then the problem may be the quotes. You’re using “ ” ‘ ’ instead of " and '.

If this does not fix it, then another problem might be that the play button doesn’t exist when your script wants to click it.

Thanks schl3ck. I didn’t copy the source directly, so I don’t think it’s the quotes. But I’ve included a screenshot of the script below to confirm.

I did modify the script to add a “await wv.waitForLoad()” in case that was the problem. But that did not resolve the issue.

Any other thoughts?

Hello. I’m a web developer.

And as i can remember. I were read from MDN. When a webpage want to play audio. The web page must be interacted by user (clicking, swipe or something).
I dont know how Scriptable work behind the scenes, but using JS to automation will must be follow that rules, i think. And you using Webview actually Safari module.

If you need more information about autoplaying in browser. " Autoplay guide for media and Web Audio APIs" is the keyword. You can google and should look for MDN’s posts first.

p/s : Just a new comer with Scriptable and just first post also.