Widget WebView and local storage

I’m trying to create a widget that displays my Microsoft Rewards. I use a WebView to access the rewards dashboard and scrape the values off the page using evaluateJavascript. This all works fine when I run it through Scriptable, and it is able to access the page if I’ve previously logged in using Safari.

Unfortunately it does not work as a widget. It seems to use a different profile for Safari which does not have access to the cached credentials. So instead of loading the rewards page it loads the login page, and of course I have no way to interact with the WebView.

image image

You can try to login through the WebView automatically. You would have to look up which element is the username, password and submit button in the HTML of the page. Then you could auto-fill these in your script. But it will sadly not work if you have enabled any kind of two factor authentication, unless it is a pin generated by a seed, but then you would need to implement that pin generation in Scriptable and redo the 2FA setup with your normal authenticator app and Scriptable simultaneously.

Thanks @schl3ck. I’ve tried to click on the sign in link from the Widget code but have not had success. As a workaround I now save the data from another script locally and then read this data from the Widget.