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

xbox series x controller microsoft

How to Pair a PS5 DualSense and Xbox Series X Controller With iPhone, iPad, and Apple TV

Monday May 10, 2021 1:07 pm PDT by
With the release of iOS 14.5 and tvOS 14.5, Apple users can now connect their PS5 DualSense and Xbox Series X controllers to an iPhone, iPad, and Apple TV. Keep reading to learn how it works. Since iOS 13 and tvOS 13, users have been able to connect popular console controllers to an iPhone or Apple TV to play Apple Arcade games and other iOS games, instead of having to spend extra money on...
how to take burst photos iphone 11

How to Delete Redundant Burst Mode Photos on iPhone and iPad

Thursday April 8, 2021 4:37 pm PDT by
Burst Mode refers to when the camera on your iOS device captures a series of photos in rapid succession, at a rate of ten frames per second. It's a great way to shoot an action scene or an unexpected event, since you're always more likely to end up with the picture you were aiming for. Whenever you take a series of burst photos, they automatically appear in the Photo app under the Album name ...
mozilla firefox banner

How to Clear Cookies in Firefox on Mac and iOS

Monday April 19, 2021 11:24 am PDT by
Whenever you browse the web in Firefox, the browser stores website data including cookies so that it doesn't have to do so again each time you revisit a site. In theory this should speed up your browsing experience, but there are some scenarios where you might want to clear the cache and start anew. Keep reading to learn how it's done on Mac, iPhone, and iPad. There are a couple of...
Apple Podcasts iOS 14 5

iOS 14.5: How to Automatically Download New Podcast Episodes and Follow Shows

Tuesday April 27, 2021 5:21 pm PDT by
In iOS 14.5, Apple has made some notable changes to its native Podcasts app. Some of these changes reflect the fact that Apple announced an optional paid podcast subscription service (beginning May 2021), while others are interface improvements to make it easier to find, follow, and listen to new episodes. One example of these changes is the new Smart play button, which is designed to help...
apple card 1

How to Share Your Apple Card With Family

Tuesday May 25, 2021 4:48 pm PDT by
‌Apple Card‌ Family allows families and friends to share a single ‌Apple Card‌ with users above 13 years old, and includes the ability to set a spending limit. The process for sharing an ‌Apple Card‌ with a friend or teenager is enabled on iPhones running iOS 14.6 or later and requires that you are in the same iCloud Family as the person you wish to share the card with. The...
apple card hands

How to Add a Co-Owner to Apple Card

Tuesday May 25, 2021 4:51 pm PDT by
‌Apple Card‌ enables couples to co-own a single ‌Apple Card‌, allowing them to build their credit score together. The process is similar to sharing an ‌Apple Card‌ with your teenager or friend but requires that you share your spouse's annual income. As co-owners, remember that the both of you share responsibility for all account activity, including the payment of balances. The process for ...
photos icon

How to Back Up Your iPhone Photos

Wednesday May 12, 2021 9:26 am PDT by
Backing up the photos you take on your iPhone might not sound like a thrilling prospect, but it's far from a thankless task. On the contrary, it's a crucial step in ensuring that your most precious pictures are never lost. Plus, once you have a system for backing up your photos in place, you can get on with enjoying taking pictures with your smartphone in the confidence that they're safe. You...
m1 mac family

How to Record Your Mac's Screen

Tuesday May 18, 2021 3:41 pm PDT by
If you've ever wanted to record a video of your Mac's screen but don't know quite how to do so, then you've come to the right place. Keep reading to learn how you can record any Mac desktop activity in just a few simple steps. Recording the activity on your Mac's screen can be useful for a number of reasons. For example, if you want to teach someone how to perform a particular function on...

Popular Stories

maxresdefault

Review: M1 Max MacBook Pro After Three Months

Wednesday January 19, 2022 11:30 am PST by
It's now been a few months since the M1 Pro and M1 Max MacBook Pro models launched in October, and MacRumors video editor Dan Barbera has been using one of the new machines since they debuted. Over on the MacRumors YouTube channel, Dan has shared a three month review of his MacBook Pro to see how it has held up over time and how it's changed his workflow. Subscribe to the MacRumors YouTube ...
airpodsinear 1

AirPods Save Woman's Life With Feature Everyone Should Know

Friday January 21, 2022 2:13 am PST by
Apple's AirPods have been credited with saving a woman's life after a potentially fatal fall, People reports. When a 60-year-old florist in New Jersey tripped and hit her head in her studio, she lost consciousness and awoke heavily bleeding. With nobody around to call for help, she realized she had her AirPods in, and used a "Hey Siri" command to call 911. An operator was able to stay on the ...
iphone se 2020 top

New iPhone SE Likely to Launch in April Based on Production Timeframe

Wednesday January 19, 2022 6:44 am PST by
Apple suppliers will begin producing display panels for the third-generation iPhone SE this month, with final assembly of the device likely to start in March, according to information shared by display industry consultant Ross Young. Based on this production timeframe, Young believes the third-generation iPhone SE is likely to launch in the second half of April, or perhaps in early May at...
iphone 13 earpods

Apple to Stop Including EarPods With Every iPhone Sold in France From Next Week

Friday January 21, 2022 3:21 am PST by
Apple will no longer include EarPods with every iPhone sold in France, starting on January 24, according to a notice posted by a French carrier (via iGeneration). Apple was previously required to include EarPods in the box with the iPhone due to a French law that required every smartphone sold in the country to come with a "handsfree kit," but the law has now been changed in favor of reducing the ...
Spring 2022 Apple Products Feature

New iPad Air, Macs, and iPhone SE With 5G Likely to Be Announced at Apple Event This Spring

Thursday January 20, 2022 8:32 am PST by
Earlier this week, Bloomberg's Mark Gurman tweeted that Apple "will be holding a spring event" to announce a new iPhone SE and other hardware. In a recent edition of his newsletter, Gurman said the event is likely to occur in March or April. Gurman did not elaborate on what "other hardware" will be announced at Apple's purported spring event, but rumors suggest at least four products are...
appleeducation

Apple's US Education Store Now Requires Institution Verification to Buy Discounted Products

Wednesday January 19, 2022 2:22 am PST by
Apple is now requiring that customers in the United States verify that they're active students, teachers, or staff members at an educational institution in order to access education discounts on products. Previously, little verification was needed for customers to purchase products through Apple's education store in the United States. Apple's education stores offer models of the iPad and Mac ...
AirPods 3 New Firmware Feature

Apple Updates AirPods 3 Firmware to Version 4C170

Tuesday January 18, 2022 11:46 am PST by
Apple today released a new 4C170 firmware update for the AirPods 3, an update from the prior 4C165 that was made available in December. Apple does not offer details on what's included in new firmware updates for the AirPods‌, so we don't know what improvements or bug fixes the new firmware brings. There is no standard way to upgrade the ‌AirPods‌‌ software, but firmware is...
appleprivacyad cleaned

iOS 15 Patched Security Hole That Potentially Exposed Users' Private Apple ID Information to Third-Party Apps

Thursday January 20, 2022 3:32 am PST by
Apple patched two significant security vulnerabilities when it released iOS 15 that could have potentially exposed users' private Apple ID information and in-app search history to malicious third-party apps and allowed apps to override user Privacy preferences, Apple has revealed in a recent support document update. With most iOS, macOS, tvOS, and watchOS updates, Apple provides a list of...
apple watch series 7 aluminum colors yellowbg

Apple Watch Charging Bug Fixed in watchOS 8.4 Release Candidate

Thursday January 20, 2022 4:01 pm PST by
The watchOS 8.4 release candidate that was seeded to developers and beta testers this morning addresses an ongoing bug that could cause some Apple Watch chargers not to work properly with the Apple Watch. Back in December, we reported on a growing number of charging issues that Apple Watch Series 7 owners were facing. Since watchOS 8.3, there have been a number of complaints about...