-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpatcher-gui.applescript
More file actions
71 lines (63 loc) · 3.07 KB
/
patcher-gui.applescript
File metadata and controls
71 lines (63 loc) · 3.07 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
on replace_text(findText, replaceText, sourceText)
set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to findText
set textItems to text items of sourceText
set AppleScript's text item delimiters to replaceText
set resultText to textItems as string
set AppleScript's text item delimiters to oldTIDs
return resultText
end replace_text
on escape_json(value)
set value to replace_text("\\", "\\\\", value)
set value to replace_text("\"", "\\\"", value)
set value to replace_text(return, "\\n", value)
return value
end escape_json
set modeChoices to {"Installed Equicord", "Installed Vencord", "Source Repo (Vencord)", "Source Repo (Equicord)"}
set selectedMode to choose from list modeChoices with prompt "Choose where to install the FileSplitter patch" default items {"Installed Equicord"} without multiple selections allowed and empty selection allowed
if selectedMode is false then return
set modeLabel to item 1 of selectedMode
if modeLabel is "Installed Equicord" then
set modeKey to "installed"
set sourceFlavor to ""
set actionChoices to {"Install / Update", "Status", "Restore"}
set defaultFolder to POSIX file ((POSIX path of (path to home folder)) & "Library/Application Support/Equicord")
else if modeLabel is "Source Repo (Vencord)" then
set modeKey to "source"
set sourceFlavor to "vencord"
set actionChoices to {"Install / Update", "Status"}
set defaultFolder to path to desktop folder
else if modeLabel is "Installed Vencord" then
set modeKey to "installed-vencord"
set sourceFlavor to ""
set actionChoices to {"Install / Update", "Status", "Restore"}
set defaultFolder to POSIX file ((POSIX path of (path to home folder)) & "Library/Application Support/Vencord")
else
set modeKey to "source"
set sourceFlavor to "equicord"
set actionChoices to {"Install / Update", "Status"}
set defaultFolder to path to desktop folder
end if
set selectedAction to choose from list actionChoices with prompt "Choose action" default items {"Install / Update"} without multiple selections allowed and empty selection allowed
if selectedAction is false then return
set actionLabel to item 1 of selectedAction
if actionLabel is "Install / Update" then
set actionKey to "install"
else if actionLabel is "Status" then
set actionKey to "status"
else
set actionKey to "restore"
end if
set chosenFolder to choose folder with prompt "Select the target folder" default location defaultFolder
set chosenPath to POSIX path of chosenFolder
set restartValue to "false"
if modeKey is "installed" or modeKey is "installed-vencord" then
set restartDialog to display dialog "Restart Discord automatically after install or restore?" with title "FileSplitter Patcher" buttons {"No", "Yes"} default button "Yes"
if button returned of restartDialog is "Yes" then set restartValue to "true"
end if
set json to "{\"action\":\"" & actionKey & "\",\"mode\":\"" & modeKey & "\",\"path\":\"" & escape_json(chosenPath) & "\",\"restartClient\":" & restartValue
if sourceFlavor is not "" then
set json to json & ",\"sourceFlavor\":\"" & sourceFlavor & "\""
end if
set json to json & "}"
return json