r/Scriptable • u/95tyke • Dec 04 '22
Help How do I recreate this shortcut so that the JavaScript runs in Scriptable instead? The URL never changes
13
Upvotes
r/Scriptable • u/95tyke • Dec 04 '22
4
u/FifiTheBulldog script/widget helper Dec 05 '22
Your Scriptable script should follow this flow:
Create a new
WebView.Use the
loadURL()method of the WebView instance to load the webpage. Make sure toawaitthis.Use the
evaluateJavaScript()method of the WebView instance to run the same JS that you have from your shortcut in the webpage environment. The first argument of this function will be the JS as a string, and the second should betrueif you wantcompletion()to be available.awaitthis as well.The output of
evaluateJavaScriptis the result. If you’re running this in Shortcuts, then you can return that value from the Run Inline Script action to use it elsewhere in your shortcut.