forked from hoythan/Scriptable-Audi
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall-runtime.js
More file actions
28 lines (28 loc) · 931 Bytes
/
install-runtime.js
File metadata and controls
28 lines (28 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const alert = new Alert()
alert.title = '大众集团 iOS 桌面挂件下载器'
alert.message = '根据您的对应车企进行下载对应的脚本'
const menuList = [
{
name: 'FVW-Audi-Joiner.js',
text: '一汽奥迪'
},
{
name: 'FVW-Joiner.js',
text: '一汽大众'
},
{
name: 'Comfort-Joiner.js',
text: '体验版'
}
]
menuList.forEach(item => {
alert.addAction(item.text)
})
const menuId = await alert.presentSheet()
const obj = menuList[menuId]
const FILE_MGR = FileManager[module.filename.includes('Documents/iCloud~') ? 'iCloud' : 'local']()
let REQ = new Request(`https://cdn.jsdelivr.net/gh/JaxsonWang/Scriptable-VW@latest/build/${encodeURIComponent(obj.name)}`)
const RES = await REQ.load()
FILE_MGR.write(FILE_MGR.joinPath(FILE_MGR.documentsDirectory(), obj.name), RES)
FILE_MGR.remove(module.filename)
Safari.open('scriptable:///run?scriptName='+encodeURIComponent(obj.name[0]))