[BUG] User scripts errors on Mobile (QuickAdd 0.5.0)
See original GitHub issueDescription
On two scripts, I’ve noticed errors when trying to launch them on mobile.
To reproduce
Script 1
When launching your Movie and Series script, I get the following error :
Error: Failed to load. Cleartext HTTP traffic to www.omdbapi.com not permitted
It seems that writing :
const API_URL = "https://www.omdbapi.com/";
Instead of :
const API_URL = "http://www.omdbapi.com/";
At line 5 of your script solves the problem ?
Script 2
When launching my Video game script, I get the following error :
TypeError: QuickAdd.app.vault.adapter.getBasePath is not a function
Apparently there is a problem with line 46 :
var basePath = QuickAdd.app.vault.adapter.getBasePath();
Maybe this does not exist on mobile ? How could I solve this issue so that it works both on mobile and still on PC ? I need to write some data to obsidian configuration folder and thus need vault path to navigate to it.
Script 3
My books script works perfectly fine on mobile (Android 12 - One UI 3.0) thanks to your 0.5.0 update !
Environment:
- Device: Galaxy S20FE
- OS: Android 12 - One UI 3.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
@Elaws Exactly that function is actually a bit harder, I believe. It’s not accessible from the window object, unlike
app
.I just released a version which exposed the Obsidian API in scripts. Then you should be able to access the function like so:
Wow @chhoumann, this is great : thank you very much !
Thanks to your help, I’ve finally been able to make script n°2 work on mobile, using the following (approximately) :
Not sure if this is clean, but it seems to work on Windows, Android 12 and iPad ^^
I thought I’d need full Obsidian API access to read/write file, but these functions are part of
app.vault
, which you already expose.