List and Dictionary Helper
COMMENT
This shortcut supports UpdateHub: https://routinehub.co/shortcut/2066
That is, you can check for updates of all UpdateHub-supported shortcuts by manually running the UpdateHub shortcut.
RoutineHubUpdate
Current Version: "2.0"
RoutineHub ID: "5176"
RoutineHubUpdate
COMMENT
Run 𝗟𝗶𝘀𝘁 𝗮𝗻𝗱 𝗗𝗶𝗰𝘁𝗶𝗼𝗻𝗮𝗿𝘆 𝗛𝗲𝗹𝗽𝗲𝗿 from your shortcut to add, replace or remove an item in a list or dictionary. Please read instructions on the RoutineHub webpage below.
2020-08-26 ⓥ2.0 @gluebyte u/gluebyte
https://routinehub.co/shortcut/5176
MATHS
Random number between
1
and
10

Random Number
SCRIPTING
If
Random Number
is
1
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
SCRIPTING
If
File
is greater than
Current Date
SCRIPTING
Otherwise
SCRIPTING
Get current IP address
Options Under Construction

Current IP Address
SCRIPTING
If
Current IP Address
has any value
NETWORK
Get contents of
https://routinehub.co/api/v1/shortcuts/5176/versions/latest
Options Under Construction

Contents of URL
SCRIPTING
Get
Value
for
Version
in
Contents of URL

Dictionary Value
SCRIPTING
If
Dictionary Value
has any value
SCRIPTING
If
Dictionary Value
is not
2.0
NOTIFICATIONS
Show notification
Dictionary Value
Options Under Construction
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
CALENDAR
Add
2
days
from
Current Date

Adjusted Date
DOCUMENTS
Save
Adjusted Date
Destination Path
/Shortcuts/List and Dictionary Helper Update Check.txtOverwrite If File Exists

Saved File
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
If
Shortcut Input
has any value
TEXT
<script>
let input =
Shortcut Input
;
val = input.value;
subo = obj = input.dictionary ?? input.list;
//if (typeof obj === "string" && obj[0]+obj[obj.length-1] === "{}") { obj = JSON.parse(obj) }
keys = [...(input.key ?? input.index).matchAll(/(?:^"|\.")([^"\\]*(?:\\.[^"\\]*)*)(?:")|(?:^|\.)([^"][^\.]*)/g)].map(arr => isNaN(k = arr[2] ?? arr[1]) ? k : parseInt(k));
last = keys.pop();
prevo = prevk = null;
keys.forEach(k => {prevo = subo; prevk = isNaN(k) ? k : k + (k < 1 ? subo.length : -1); subo = subo[prevk]});
if (isNaN(last)) {
if (val != null) { subo[last] = val } else { delete subo[last] }
} else {
if (!subo || subo.constructor !== Array) {
subo = prevk != null ? (prevo[prevk] = [subo]) : (obj = [subo]);
}
last += last < 1 ? subo.length : -1;
if (val != null) { subo.splice(last,0,val) } else { subo.splice(last,1) }
}
document.write(encodeURIComponent(JSON.stringify({"output":obj})));
</script>

Text
SCRIPTING
Encode
Text
with base64

Base64 Encoded
URL
data:text/html;charset=utf-8;base64,
Base64 Encoded

URL
SCRIPTING
URL
Decode
URL

URL Encoded Text
SCRIPTING
If
URL Encoded Text
has any value
SCRIPTING
Get
Value
for
output
in
URL Encoded Text

Dictionary Value
SCRIPTING
Otherwise
SCRIPTING
Show alert
Error in 𝙇𝙞𝙨𝙩 𝙖𝙣𝙙 𝘿𝙞𝙘𝙩𝙞𝙤𝙣𝙖𝙧𝙮 𝙃𝙚𝙡𝙥𝙚𝙧
Title
Error in 𝙇𝙞𝙨𝙩 𝙖𝙣𝙙 𝘿𝙞𝙘𝙩𝙞𝙤𝙣𝙖𝙧𝙮 𝙃𝙚𝙡𝙥𝙚𝙧
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
SCRIPTING
Show alert
Informational Message
SCRIPTING
End If

If Result
Showcuts