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

Popular Stories

space black mbp

Apple Potentially Facing Worst Leak Since iPhone 4 Was Left in a Bar

Monday October 7, 2024 3:03 pm PDT by
Alleged photos and videos of an unannounced 14-inch MacBook Pro with an M4 chip continue to surface on social media, in what could be the worst product leak for Apple since an employee accidentally left an iPhone 4 prototype at a bar in California in 2010. The latest video of what could be a next-generation MacBook Pro was shared on YouTube Shorts today by Russian channel Romancev768, just...
iPhone 17 Slim Feature Single Camera 2

10 Reasons to Wait for Next Year's iPhone 17

Tuesday October 8, 2024 5:45 am PDT by
Apple's iPhone development roadmap runs several years into the future and the company is continually working with suppliers on several successive iPhone models simultaneously, which is why we sometimes get rumored feature leaks so far ahead of launch. The iPhone 17 series is no different – already we have some idea of what to expect from Apple's 2025 smartphone lineup. If you plan to skip...
iPad mini review thumb

iPad Mini 7 Coming Next Month: What to Expect

Tuesday October 8, 2024 6:16 am PDT by
Rumors strongly suggest Apple will release the seventh-generation iPad mini in November, nearly three years after the last refresh. Here's a roundup of what we're expecting from the next version of Apple's small form factor tablet, based on the latest rumors and reports. Design and Display The new iPad mini is likely to retain its compact 8.3-inch display and overall design introduced with...
apple tv 4k yellow bg feature

Waiting for a New Apple TV? Here's What the Latest Rumors Say

Tuesday October 8, 2024 8:57 am PDT by
The current Apple TV was released two years ago this month, so you may be wondering when the next model will be released. Below, we recap rumors about a next-generation Apple TV. In January 2023, Bloomberg's Mark Gurman reported that a new Apple TV was planned for release in the first half of 2024:Beyond the future smart displays and new speaker, Apple is working on revamping its TV box....
Generic iOS 18

Everything New in iOS 18.1 Beta 6

Monday October 7, 2024 4:27 pm PDT by
We're nearing the end of the iOS 18.1 beta testing process, but Apple is continuing to make tweaks to refine built-in features ahead of when the software launches. With testing winding down, there are fewer new additions, but Apple has made changes worth noting. The new beta is available for both developers and public beta testers. Control Center In the Control Center, Apple has added new...
Prime Big Deal Days Hero 3

The Best Prime Day Deals on AirPods, Apple Watch, and More

Tuesday October 8, 2024 5:19 am PDT by
Amazon's Prime Big Deal Days event is in full swing today, offering customers the first chance to get some holiday shopping done early. Similar to the first Prime Day, it will last for two days (October 8-9) and you can find a large selection of deals across Amazon's storefront, covering savings on tech, clothing, video games, groceries, and much, much more. Note: MacRumors is an affiliate...
m4 macbook pro leak russian ad

Leaked M4 MacBook Pro Appears for Sale on Russian Classifieds Site

Wednesday October 9, 2024 2:05 am PDT by
In a continuation of the latest unprecedented leak, Apple's yet-to-be-announced M4 MacBook Pro has reportedly surfaced on Avito, a popular Russian classified ads website. The development follows recent videos from Russian YouTube channels showcasing what appears to be the unreleased laptop model. According to reports on social media, the listing on Avito advertised a 14-inch MacBook Pro...