Accepts
Safari Web Pages and URLs
DICTIONARY

Dictionary
DICTIONARY

Dictionary
VARIABLES
Set variable
mainResources
to
mainResources
TEXT
Match
redoSettings|el\=detailpage
in
Shortcut Input

Matches
SCRIPTING
If
Matches
does not have any value
NETWORK
Get contents of
https://routinehub.co/api/v1/shortcuts/
RID
/versions/latest
Options Under Construction

Contents of URL
DOCUMENTS
Get text from
Contents of URL

Text
SCRIPTING
If
LatestV
is not
VersionID
SCRIPTING
Choose from Menu

Menu Result
SCRIPTING
Update Directly

Menu Result
DOCUMENTS
Replace
^.+?(?=\/shortcut)
with
shortcuts:/
in
Contents of URL

Updated Text
SAFARI
Open
Updated Text
SCRIPTING
Exit shortcut with
Result
SCRIPTING
Skip This Time

Menu Result
SCRIPTING
End Menu

Menu Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
SCRIPTING
If
File
does not have any value
SCRIPTING
If
Shortcut Input
is not
redoSettings
SCRIPTING
Show alert
Missing Settings
SCRIPTING
Otherwise
SCRIPTING
Show alert
Reconfiguring Settings
Title
Reconfiguring Settings
SCRIPTING
End If

If Result
SCRIPTING
Choose from
mainResources
Prompt
Video Save Location

Chosen Item
SCRIPTING
Choose from
mainResources
Prompt
Audio Save Location

Chosen Item
SCRIPTING
Choose from
mainResources
Prompt
Download Notification Alerts

Chosen Item
SCRIPTING
Get
Value
for
Chosen Item
in
mainResources

Dictionary Value
SCRIPTING
Get
Value
for
Chosen Item
in
mainResources

Dictionary Value
SCRIPTING
Get
Value
for
Chosen Item
in
mainResources

Dictionary Value
TEXT
{"videoSave":"
Dictionary Value
","audioSave":"
Dictionary Value
","allowNotifs":"
Dictionary Value
"}

Text
SCRIPTING
Set name of
Text
to
YTScriptSetup.json

Renamed Item
DOCUMENTS
Save
Renamed Item
Destination Path
/Shortcuts/YTScriptSetup.jsonOverwrite If File Exists

Saved File
SCRIPTING
Show alert
Configuration Complete
Title
Configuration Complete
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
DICTIONARY

Dictionary
TEXT
allowNotifs

Text
SCRIPTING
If
Shortcut Input
does not have any value
WEB
Get URLs from
Clipboard

URLs
VARIABLES
Set variable
ytInput
to
URLs
SCRIPTING
Otherwise
VARIABLES
Set variable
ytInput
to
Shortcut Input
SCRIPTING
End If

If Result
TEXT
Match
\byoutube|\byoutu\.be(?!$)|(?<=v\=).{11}|(?<=youtu\.be\/).{11}|(?<=embed\/).{11}
in
ytInput

Matches
SCRIPTING
Count
Items
in
urlEleMatches

Count
SCRIPTING
If
urlElements
is greater than or equal to
2
SCRIPTING
Get
Last Item
from
urlEleMatches

Item from List
VARIABLES
Set variable
ytID
to
Item from List
SCRIPTING
If
ytInput
is
el=detailpage
URL
https://www.youtube.com/get_video_info?video_id=
ytID
&
ytInput

URL
SCRIPTING
Otherwise
URL
https://www.youtube.com/get_video_info?video_id=
ytID

URL
SCRIPTING
End If

If Result
NETWORK
Get contents of
If Result
Options Under Construction

Contents of URL
SCRIPTING
Get dictionary from
Contents of URL

Dictionary
SCRIPTING
Get
Value
for
simpleText
in
microformat.playerMicroformatRenderer.title

Dictionary Value
DOCUMENTS
Replace
\+(?!\+)
with
in
Dictionary Value

Updated Text
VARIABLES
Set variable
ytFTitle
to
Updated Text
TEXT
Match
^.{30}
in
ytFTitle

Matches
SCRIPTING
Count
Characters
in
ytFTitle

Count
SCRIPTING
If
Count
is greater than
30
TEXT
Current Video:
Matches
...

Text
SCRIPTING
Otherwise
TEXT
Current Video:
ytFTitle

Text
SCRIPTING
End If

If Result
VARIABLES
Set variable
titleInfo
to
If Result
SCRIPTING
Get
Value
for
url
in
microformat.playerMicroformatRenderer.thumbnail.thumbnails

Dictionary Value
VARIABLES
Set variable
thumbURL
to
Dictionary Value
SCRIPTING
Get type of
ytInput

Type
SCRIPTING
If
Type
contains
Safari
SAFARI
Run JavaScript on
ytInput
Options Under Construction

JavaScript Result
SCRIPTING
Get
First Item
from
JavaScript Result

Item from List
SCRIPTING
If
Item from List
does not contain
Mobile
SCRIPTING
Show alert
Incompatible Website
Title
Incompatible Website
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
SCRIPTING
Get
Last Item
from
JavaScript Result

Item from List
VARIABLES
Set variable
ytMaxQURL
to
Item from List
SCRIPTING
Otherwise
SCRIPTING
Get dictionary from
streamingData

Dictionary
SCRIPTING
Get dictionary from
formats

Dictionary
SCRIPTING
Get
First Item
from
Dictionary

Item from List
SCRIPTING
Get
Value
for
url
in
Item from List

Dictionary Value
VARIABLES
Set variable
ytMinQURL
to
Dictionary Value
SCRIPTING
Get
Last Item
from
Dictionary

Item from List
SCRIPTING
Get
Value
for
url
in
Item from List

Dictionary Value
VARIABLES
Set variable
ytMaxQURL
to
Dictionary Value
SCRIPTING
If
ytMaxQURL
does not have any value
SCRIPTING
If
ytInput
is
el=detailpage
SCRIPTING
Show alert
Protected Stream
TEXT
<html>
<head>
<title>YTScript - Redirect</title>
</head>
<body onload="YTopen()">
<script>
function YTopen() {
window.location = "https://www.youtube.com/watch?v=
ytID
";
}
</script>
</body>
</html>

Text
URL
data:text/html,
Text

URL
SAFARI
Open
URL
SCRIPTING
Exit shortcut with
Result
SCRIPTING
Otherwise
TEXT
el=detailpage

Text
SCRIPTING
Set name of
ytInput
to
Text

Renamed Item
SHORTCUTS

Shortcut Result
SCRIPTING
Exit shortcut with
Result