-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
33 lines (33 loc) · 1.05 KB
/
Copy pathinit.js
File metadata and controls
33 lines (33 loc) · 1.05 KB
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
29
30
31
32
33
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: green; icon-glyph: magic;
//does all the setup a script can do.
const VERSION="1.2.0"
//makes a clipboard folder
let fm=FileManager.iCloud()
if (!fm.fileExists(fm.joinPath(fm.documentsDirectory(), "clipboards"))){
fm.createDirectory(fm.joinPath(fm.documentsDirectory(), "clipboards"))
}
//initializes keychain
const eddaLib=importModule(n.bookmarkedPath("eddaLib"))
let dir=fm.documentsDirectory()
async function loadNames(){
let path = fm.joinPath(dir, "names.txt")
if (!fm.isFileDownloaded(path)) {
await fm.downloadFileFromiCloud(path)
}
let text = fm.readString(path)
let list = []
for (let line of text.split("\n")) {
line = line.trim()
if (!line || line.startsWith("#")) continue
list.push(line)
}
for (let name of list) {
let a=eddaLib.prompt("Data Entry",name+":","")
if (a===null) continue
if (a=="null") {a=null}
Keychain.set(name,a)
}
}
await loadNames()