YouTube Safari iOS PiP Block Unblocker

Unblocks the block of Picture-in-Picture mode for m.youtube.com on Safari iOS. Works as of 2025-01-31.

  1. // ==UserScript==
  2. // @name YouTube Safari iOS PiP Block Unblocker
  3. // @version 1.0
  4. // @description Unblocks the block of Picture-in-Picture mode for m.youtube.com on Safari iOS. Works as of 2025-01-31.
  5. // @author ILoveYouTube
  6. // @match https://m.youtube.com/*
  7. // @grant none
  8. // @license MIT
  9. // @namespace https://greasyfork.org/users/1429466
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // iOS Safari needs a user interaction first before we can modify video elements
  16. document.addEventListener('touchstart', function initOnTouch() {
  17. let v = document.querySelector('video');
  18. if (v) {
  19. v.addEventListener('webkitpresentationmodechanged', (e)=>e.stopPropagation(), true);
  20. // Remove the touchstart listener after we've initialized
  21. document.removeEventListener('touchstart', initOnTouch);
  22. }
  23. }, true);
  24. })();