COMMENT
This shortcut is for shortcut developers only. Users of shortcuts with Embed-a-Update do not have to install anything.
SCRIPTING
Repeat
Count

Repeat Results
COMMENT
[Eᴍʙᴇᴅ-ᴀ-Uᴘᴅᴀᴛᴇ]
Set ID and Version below.
Make sure to update Version every time you update your shortcut.
DICTIONARY

Dictionary
VARIABLES
Set variable
LocalData
to
Dictionary
SCRIPTING
Get current IP address
Options Under Construction

Current IP Address
SCRIPTING
Count
Items
in
Current IP Address

Count
SCRIPTING
If
Count
is
0
COMMENT
[Eᴍʙᴇᴅ-ᴀ-Uᴘᴅᴀᴛᴇ] Could not check for updates, there is no internet connection.
SCRIPTING
Otherwise
URL
https://routinehub.co/api/v1/shortcuts/
LocalData
/versions/latest

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
If
result
contains
success
DICTIONARY

Dictionary
TEXT
<html><head></head><body><script>
// Embed-a-Engine 1.0
function cmp (a, b) {
let pa = a.split('.');
let pb = b.split('.');
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
let na = Number(pa[i]);
let nb = Number(pb[i]);
if (isNaN(na)) na = 0;
if (isNaN(nb)) nb = 0;
if (na > nb) return "RollbackAvailable";
if (nb > na) return "UpdateAvailable";
}
return "NoChanges";
};
let data =
CompareVersionsData
;
document.write(cmp(data.current, data.new));
</script></body></html>

Text
URL
data:text/html,
CompareVersionsHTML

URL
SAFARI
Get contents of web page at
URL

Contents of Web Page
SCRIPTING
If
Contents of Web Page
is
NoChanges
COMMENT
[Eᴍʙᴇᴅ-ᴀ-Uᴘᴅᴀᴛᴇ] No updates are available at this time.
SCRIPTING
Otherwise
SCRIPTING
If
Contents of Web Page
is
RollbackAvailable
TEXT
A rollback is available:
LocalData
↘
Remote

Text
SCRIPTING
Otherwise
TEXT
An update is available:
LocalData
→
Remote

Text
SCRIPTING
End If

If Result
SCRIPTING
Choose from Menu

Menu Result
SCRIPTING
Install result (Version)

Menu Result
URL
https://routinehub.co/download/
Remote

URL
SAFARI
Open
URL
SCRIPTING
Exit shortcut with
URL
SCRIPTING
Not now

Menu Result
SCRIPTING
End Menu

Menu Result
SCRIPTING
End If

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

If Result
SCRIPTING
End If

If Result
SCRIPTING
End Repeat

Repeat Results
TEXT
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.comment</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFCommentActionText</key>
<string>[[Embed-a-Here]]</string>
</dict>
</dict>

Text
SHORTCUTS
Get my shortcuts

My Shortcuts
SCRIPTING
Choose from
My Shortcuts

Chosen Item
VARIABLES
Set variable
shortcut
to
Selected Item
SCRIPTING
Set name of
shortcut
to
a.plist

Renamed Item
SCRIPTING
Set name of
Renamed Item
to
a.plist

Renamed Item
SCRIPTING
If
Renamed Item
contains
Text
SCRIPTING
Otherwise
SCRIPTING
Show alert
Informational Message
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
SCRIPTING
Choose from Menu

Menu Result
SCRIPTING
Embed-a-Update!

Menu Result
URL
https://raw.githubusercontent.com/pfgithub/embed-a-update/master/embed.plist

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
End Menu

Menu Result
DOCUMENTS
Replace
Text
with
Menu Result
in
Renamed Item

Updated Text
SCRIPTING
Set name of
Updated Text
to
shortcut
.shortcut

Renamed Item
DOCUMENTS
Get link to
Renamed Item

Link to File
SAFARI
Open
Link to File