generated from extratone/latte
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Action Editor.jelly
122 lines (113 loc) · 4.96 KB
/
Action Editor.jelly
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import Shortcuts
#Color: green, #Icon: textBox
/*
Shortcut action editor
2024-06-21 v1.1.1
https://routinehub.co/user/gluebyte
https://mastodon.social/@gluebyte
*/
randomNumber(min: 1, max: 2) >> randomNumber
if(Random Number == 1) {
getIP() >> getIP
if(Current IP Address != nil) {
downloadURL(url: "https://updatecheck.gluebyte.workers.dev/?id=8B45C2A9") >> downloadURL
if(Contents of URL .contains "2024-06-21") { >> IFResult
menu(, [🌏 Go to RoutineHub, 👾 Download Update, ⮐ Not Now]) {
case("🌏 Go to RoutineHub"): >> MenuResult
openURL(url: "https://routinehub.co/shortcut/18280/") >> openURL
exit()
case("👾 Download Update"): >> MenuResult 1
downloadURL(url: "https://routinehub.co/api/v1/shortcuts/18280/versions/latest") >> downloadURL 1
matchText(text: "${Contents of URL}", regex: "(?<="id":\D?)\d+") >> matchText
expandURL(url: "https://routinehub.co/download/${Matches}/") >> expandURL
replaceText(input: "${Expanded URL}", find: "^.+icloud.com/", replace: "shortcuts://", isRegex: true) >> replaceText
openURL(url: Updated Text) >> openURL 1
exit()
case("⮐ Not Now"):
} >> MenuResult 2
} >> IFResult 1
} >> IFResult 2
} >> IFResult 3
if(ShortcutInput != nil) { >> IFResult 4
runJavascriptOnWebpage(javascript: "window.close();
completion();") >> runJavascriptOnWebpage
valueFor(key: "actions", dictionary: ShortcutInput) >> valueFor
repeatEach(Dictionary Value) {
setName(input: Repeat Item, name: "a.json") >> setName
getFileOfType(input: Renamed Item, type: "com.apple.plist") >> getFileOfType
setName(input: File of Type, name: "a.plist") >> setName 1
/*
Please install the Actions app
https://apps.apple.com/app/id1586435171
*/
//Unable to get shortcuts action com.sindresorhus.Actions.SetUniformTypeIdentifier
} >> RepeatResult
setClipboard(variable: Repeat Results) >> setClipboard
getClipboard() >> getClipboard
count(input: Clipboard) >> count
if(Count == 1) {
alert(alert: "
📋 Updated action copied to clipboard 📋
", tincel: false)
} else {
alert(alert: "
📋 ${Count} actions copied to clipboard 📋
", tincel: false)
} >> IFResult 5
} else {
if(Clipboard != nil) { >> IFResult 6
/*
Please install the Actions app
https://apps.apple.com/app/id1586435171
*/
//Unable to get shortcuts action com.sindresorhus.Actions.GetUniformTypeIdentifierIntent
} >> IFResult 7
if(Uniform Type Identifier .contains "com.apple.shortcuts.action") {
repeatEach(Clipboard) { >> RepeatResult 1
setName(input: Repeat Item, name: "a.plist") >> setName 2
getFileOfType(input: Renamed Item, type: "public.json") >> getFileOfType 1
replaceText(input: "${File of Type}", find: "\u0023", replace: "\\u0023", isRegex: true) >> replaceText 1
} >> RepeatResult 2
setValue(key: "json", value: "${Repeat Results.as(Dictionary)}") >> setValue
if(DeviceDetails !=) {
text(text: "setTimeout(window.close,500);") >> text
} >> IFResult 8
var E7D3CEA6-89C7-49AF-AC04-B4216E3E642F = """<html><meta charset="utf-8"><meta name="viewport" content="width=device-width, maximum-scale=1">
<style>
body { background: #eee; color: #222; }
a { display: inline-block; background-color: #5c6; font-family: system-ui; font-weight: bold; text-align: center; cursor: pointer; padding: 0.8em 1em; border-radius: 16px; }
@media (prefers-color-scheme: dark) { body { background: #222; color: #ddd; } a { background-color: #2b4; } }
</style>
<title>Action Editor</title>
<body>
<div id="input" contenteditable autofocus spellcheck="false" autocorrect="off" autocapitalize="none" style="width: 100%; min-height: 300px; font-family: monospace; font-size: 15px; word-break: break-all; white-space: pre-wrap; caret-color: red; outline: none;"></div>
<center><a onclick="finish()">Finish & Copy</a></center>
</body>
<script>
let j = .json;
document.getElementById("input").innerText = (Array.isArray(j) ? j : [j]).map(a=>JSON.stringify(a,null,2)).join('\n\n').replace(/[\0-\x08\x0B-\x1F\x7F-\xA0\xAD\u2000-\u200B\u2028\u2029\u202F\u205F-\u2064\u2800\u3000\uFFFC]/g, c=>'\\u'+c.charCodeAt(0).toString(16).toUpperCase().padStart(4,'0'));
function finish() {
try{
js=JSON.parse('[' + document.getElementById('input').innerText.split('\n\n').join(',') + ']');

location.href = 'shortcuts://run-shortcut?name=Action%20Editor&input=' + encodeURIComponent('{"actions":' + JSON.stringify(js) + '}');
} catch { alert('\n\n🛑 Invalid JSON format\n\n'); }
}
</script></html>"""
text("${E7D3CEA6-89C7-49AF-AC04-B4216E3E642F}")
if(DeviceDetails ==) { >> IFResult 9
randomNumber(min: 0, max: 99999) >> randomNumber 1
setName(input: Text, name: "Action Editor${Random Number}.html") >> setName 3
openIn(input: Renamed Item) >> openIn
wait()
} else { >> 1
decodeURL(url: "${Text}") >> decodeURL
url(url: "data:text/html,${URL Encoded Text}") >> url
openURL(url: URL) >> openURL 2
} >> IFResult 10
} else { >> 11
alert(alert: "
🛑 No shortcut actions in clipboard
", title: "", cancel: false)
} >> IFResult 11
} >> IFResult 12