code everywhere

Enable YouTube picture-in-picture on iOS 14 Safari with this Siri Shortcut

posted on September 21, 2020, 8:06 pm in

With the launch of iOS 14, YouTube's Product Managers have decided to block picture-in-picture mode in mobile Safari.

This is kind of a dick move on their part, they want you to buy Premium, but I doubt this is the way to convince people.

Luckily, Safari uses webkit and the web is open (for now anyway). We should be able to bypass this block using normal Javascript and no external plugins.

Step 1 - Find the trigger

After inspecting the page, it looks like they're using an event called webkitpresentationmodechanged, to suppress PiP mode.

Step 2 - Prevent it from activating

It's very hard to remove anonymous event listeners without a reference, so let's just stop it from triggering. We can do this by adding our own event to trigger first and prevent it from bubbling up.

Step 3 - Trigger PiP mode automatically

To save us a few clicks, in Safari, we can call webkitSetPresentationMode() to trigger PiP automatically.

Heres The full Code

let v document.querySelector('video');

v.addEventListener('webkitpresentationmodechanged', (e)=>e.stopPropagation(), true);
setTimeout(()=>v.webkitSetPresentationMode('picture-in-picture'), 3000);


And what your Shortcut should look like:

recent posts

< back
find something helpful? send us some coin BTC 19u6CWTxH4cH9V2yTfAemA7gmmh7rANgiv

(ad) Need Hosting? Try Linode, VPS Starting from $5

privacy policy