In iOS 14, Apple added a Picture in Picture mode on iPhone that lets you watch a video in a small screen on your device while you continue to do other things on the phone.

YouTube Picture in Picture
Picture in Picture mode doesn't work in the YouTube app, although it was possible to watch videos in Picture in Picture on YouTube's mobile website through Safari until YouTube intentionally nixed the workaround last week, presumably to push people to buy a Premium subscription. For a short while, you could still get Picture in Picture to work on YouTube.com in Safari if you request the desktop site, but YouTube has since blocked that as well.

But thanks to CodeEverywhere, there's now another neat workaround that uses a snippet of JavaScript and no external plugins to suppress the Picture in Picture block that YouTube has added to its mobile site.

As noted by CodeEverywhere, the same code can also be used in an iOS Shortcut that can then be selected from Safari's Activity view (formerly called the Share Sheet) whenever you want to watch a YouTube-hosted video in Picture in Picture.

Using CodeEverywhere's script, software engineer Jonas Reitmann has since created a Shortcut and made it available for download (Note: people are having trouble with the direct download shortcut working. Follow the directions below), but if you are uncomfortable downloading a shortcut blindly, you can recreate it with the steps below.

How to Create a Shortcut for YouTube Picture in Picture

  1. Launch the Shortcuts app on your ‌iPhone‌ and click the plus (+) icon in the top-right corner of the screen to create a new shortcut.
    shortcuts

  2. Tap Add Action.
    shortcuts

  3. Select Web.
    shortcuts

  4. Under "Safari," select Run JavaScript on Web Page.
    shortcuts

  5. Where it says "Run JavaScript on" tap the blue words Web Page, then select Shortcut Input in the pop-up menu.
    shortcuts

  6. Remove the existing JavaScript code in the shortcut window and paste in the following code:
    let v = document.querySelector('video');

    v.addEventListener('webkitpresentationmodechanged', (e)=>e.stopPropagation(), true);

    setTimeout(()=>v.webkitSetPresentationMode('picture-in-picture'), 3000);

    completion()
    shortcuts

  7. Tap the three dots icon in the top-right corner of the screen.
    shortcuts

  8. Give your shortcut a name, e.g. "YouTube PiP," then toggle the switch next to Show in Share Sheet to the green ON position.
    shortcuts

  9. Tap Share Sheet Types, then select Deselect All and tap Safari web pages.
    shortcuts

  10. Return to the Details screen, then tap Done.
    shortcuts

  11. Tap Done to finish.
    shortcuts

With that done, simply select the Shortcut in Safari via the Action icon whenever you want to use Picture in Picture on YouTube's mobile website, no premium subscription required.

safari

Related Forum: iOS 14

Related Stories

icloudkeychain

iOS 15.4: How to Add Notes to iCloud Keychain Entries

Tuesday February 1, 2022 4:23 pm PST by
In iOS 15.4, currently in beta, Apple has added the ability for users to add notes to account entries in iCloud Keychain. This article explains how it's done. Slowly but surely with each iteration of iOS, Apple has been improving iCloud Keychain to put it on equal footing with rival third-party password managers such as 1Password. And in iOS 15.4, it continues that tradition with a simple...
iOS 15

iOS 15.4: How to Scan Printed and Handwritten Notes into the Notes App

Tuesday March 22, 2022 10:41 am PDT by
With the release of iOS 15.4 and iPadOS 15.4, Apple added a new feature to the stock Notes app that allows you to quickly scan printed or handwritten text and save it in digital text format. Keep reading to learn how it works. On earlier versions of iOS 15 and iPadOS 15, scanning text into Apple's Notes app required tapping on a note's text field and tapping the Live Text option in the...
apple watch activity sharing

How to Share Your Activity on Apple Watch and Compete With Friends

Tuesday February 22, 2022 5:10 pm PST by
If you've got an Apple Watch, you can build motivation to stay active and stick to your fitness routine by sharing your activity with your friends and family. Read on to learn how. One of the great things about Apple Watch is that Apple has built in a social aspect to its activity tracking features that makes it easier to promote camaraderie in pursuit of a shared exercise goal. By...
shortcuts automation

iOS 15.4: How to Turn Off Notifications for Personal Automations in Shortcuts

Monday February 7, 2022 1:01 pm PST by
Apple's Shortcuts app is a great part of iOS because it includes tools that allow you to automate almost any action you can think of. But there is one aspect of it that has often annoyed users, and that's the lack of a setting that turns off notifications. Whenever Shortcuts runs an automation (let's say, disable rotation lock when a particular app is opened) it does so in the background....
Instagram Feature 2

How to Hide Your Instagram Online Status

Wednesday January 12, 2022 9:43 am PST by
Most social media networks and chat platforms these days include a feature that shows when a user was last online or last active on the service, which can be either helpful or a hindrance, depending on your personal or business situation. WhatsApp includes an optional "Last Seen" status for the person you're chatting with in a conversation thread, while Instagram tells you how long it was...
split view 4

How to Use Split Screen on iPad

Thursday January 27, 2022 5:49 pm PST by
In iPadOS, Apple includes several multitasking options that let you work with more than one app on your iPad at the same time. This allows apps that support multitasking to be used in a few different ways. This article looks at Split View, which makes two apps appear side by side in a split screen arrangement. Be sure to check out our separate Slide Over how-to guide by clicking the link. We've...
ipad kids playing

How to Limit What a Toddler Can Do When You Hand Over Your iPhone or iPad

Monday December 20, 2021 3:58 am PST by
If you've ever handed your iPhone or iPad to a baby or toddler to entertain them while you do something else, you'll probably know just how easily their little fingers can navigate into all manner of screens and settings they shouldn't be messing with. Fortunately, Apple includes a feature in iOS that allows you to keep your device locked into a single app and control which features are...
twitter pin conversations

How to Pin Twitter Direct Messages to the Top of Your Inbox

Thursday February 24, 2022 10:10 am PST by
Twitter has added a new feature to its official iOS app that allows you pin chats to the top of your inbox. This article explains how it's done. Previously only available if you were a paying Twitter Blue subscriber, anyone who uses Twitter's official app for iPhone and iPad can now make their favorite direct message conversations easily accessible by pinning them to the top of the inbox....

Popular Stories

top stories 2jul2022

Top Stories: M2 MacBook Air Release Date, New HomePod Rumor, and More

Saturday July 2, 2022 6:00 am PDT by
The M2 MacBook Pro has started making its way into customers' hands and we're learning more about how it performs in a variety of situations, but all eyes are really on the upcoming M2 MacBook Air which has seen a complete redesign and should be arriving in a couple of weeks. Other top stories this week included a host of product rumors including additional M2 and even M3 Macs, an updated...
Mac Studio IO

Apple Begins Selling Refurbished Mac Studio Models

Thursday June 30, 2022 7:42 pm PDT by
Apple today began selling refurbished Mac Studio models for the first time in the United States, Canada, and select European countries, such as Belgium, Germany, Ireland, Spain, Switzerland, the Netherlands, and the United Kingdom. In the United States, two refurbished Mac Studio configurations are currently available, including one with the M1 Max chip (10-core CPU and 24-core GPU) for...
macbook air m2

Exclusive: Apple Plans to Launch MacBook Air With M2 Chip on July 15

Wednesday June 29, 2022 5:23 pm PDT by
The redesigned MacBook Air with the all-new M2 Apple silicon chip will be available for customers starting Friday, July 15, MacRumors has learned from a retail source. The new MacBook Air was announced and previewed during WWDC earlier this month, with Apple stating availability will begin in July. The MacBook Air features a redesigned body that is thinner and lighter than the previous...
13 inch macbook pro m2 mock feature 2

M2 MacBook Pro Much Slower Than Previous Model

Friday July 1, 2022 2:24 am PDT by
Apple's new 13-inch MacBook Pro with the M2 chip features a significantly slower SSD compared to the previous model, resulting in poorer performance in some workflows, it has been discovered. Specifically, it has been found that the $1,299 base model with 256GB of storage has significantly slower SSD read and write speeds compared to the equivalent previous-generation 13-inch MacBook Pro....