ShareShortcuts

uTube PiP

Usage: Minimize any YouTube video you want from safari or YouTube application

arirafiq
Fork “uTube PiP”

Built something new on top of this Shortcut? Share it as a fork: it becomes a Shortcut of your own, which you manage, and both pages link to each other so arirafiq gets credit.

  1. 1Get the Shortcut and change it in the Shortcuts app. Give it a name of its own.
  2. 2Share it from the Shortcuts app and copy the iCloud link.
  3. 3Come back here, paste the link and describe what is different, e.g. “Added a step that uses Apple Intelligence to personalise the text.”
Downloads
57K
Saved
2
Actions
49
Category
Streaming
Version
1.0
Language
EN

Preview

Usage:

Minimize any YouTube video you want from safari or YouTube application.

What's New

Version 1.0

First release

Version History
1.0 Mar 25, 2021

First release

What it does

49 actions
  1. Comment
    Author: Ari R. Abdulla Usage: Minimize any YouTube video you want.
  2. If
  3. Get Type
  4. Set Variable
    Shortcut Type
  5. If
  6. Text
  7. If
  8. Run JavaScript on Web Page
  9. Stop This Shortcut
  10. If
  11. Show Alert
  12. Stop This Shortcut
  13. If
  14. Text
  15. Set Variable
    Shortcut Text
  16. If
  17. Set Variable
    Shortcut Input
  18. Nothing
  19. If
  20. Show Alert
  21. Stop This Shortcut
  22. If
  23. Get Clipboard
  24. If
  25. Set Variable
    Shortcut Input
  26. Nothing
  27. If
  28. If
  29. Set Variable
    Shortcut Input
  30. Nothing
  31. If
  32. Show Alert
  33. Stop This Shortcut
  34. URL
    …
  35. Set Variable
    Link
  36. If
  37. Nothing
  38. If
  39. Replace Text
  40. Set Variable
    Link
  41. Text
  42. Run Script Inline
    dk.simonbs.Scriptable
  43. Get Dictionary from Input
  44. Get Dictionary Value
  45. Set Variable
    FinalURL
  46. Open URLs
  47. Wait
  48. Open App
  49. Stop This Shortcut

View as code
Beta

Every action of this Shortcut written out as Cherri, a programming language for Shortcuts. Great for learning how it works.

#include 'actions/web'
#define color darkblue
#define glyph shrinkArrow

/*
Author: Ari R. Abdulla
Usage:
Minimize any YouTube video you want.
*/

if ShortcutInput {
	typeOf(ShortcutInput)
	@ShortcutType
	if @ShortcutType contains "Safari" {
		const Text = "{ShortcutInput}"
		if Text contains "youtube.com" {
			runJavaScriptOnWebpage("let v = document.querySelector('video');\nv.addEventListener('webkitpresentationmodechanged', (e)=>e.stopPropagation(), true);\n\nsetTimeout(()=>v.webkitSetPresentationMode('picture-in-picture'), 3000);\n\ncompletion()")
			stop()
		} else {
			confirm("It seems that it's not a YouTube Link!!!")
			stop()
		}
	} else {
		@ShortcutText = "{ShortcutInput}"
		if @ShortcutText contains "youtube.com" {
			@ShortcutInput = @ShortcutText
		} else {
			confirm("It seems that it's not a YouTube Link!!!")
			stop()
		}
	}
} else {
	const Clipboard = getClipboard()
	if Clipboard contains "youtube.com" {
		@ShortcutInput = Clipboard
	} else {
		if Clipboard contains "youtu.be" {
			@ShortcutInput = Clipboard
		} else {
			confirm("First copy one YouTube link!")
			stop()
		}
	}
}
url(@ShortcutInput)
@Link

if @Link contains "watch" {
} else {
	replaceText("youtu.be/", "youtube.com/watch?v=", @Link)
	@Link
}
rawAction("dk.simonbs.Scriptable.RunScriptInlineIntent", {
	"Show-texts": true,
	"Show-urls": true,
	"ShowWhenRun": false,
	"runInApp": false,
	"script": "let url = \\\"{@Link}\\\", \\ncitem = \\\"Download Video\\\";\\n{}"
})
const Dictionary = getDictionary(Output)
@FinalURL = Dictionary['url']
openURL(@FinalURL)
wait(5)
openApp("com.google.ios.youtube")
stop()
Open in Cherri Playground Decompiled with cherri 2.3.0 (GPL-2.0). May need small fixes before it compiles.

Ratings & Reviews

Write a Review
–
out of 5
★★★★★
★★★★
★★★
★★
★
0 ratings

No reviews yet. Be the first to share what you think!

Advertisement

More by arirafiq

See All

You Might Also Like

See All
Advertisement