Create your own Picture-In-Picture video feature bookmarklet
Cover image by charlesdeluvio
...
Some websites & video streaming services have a feature that allows you to watch videos in Picture-in-Picture mode, but they lock this feature behind some kind of paywall or make it a perk of having a subscription.
Some websites just don't have this feature altogether!
I find this infuriating, as this is a feature that is built into all modern web browsers and is free to use for those who know how to do it with no special effort, purchases, plugins or hack.
Here's how to do it:
Option 1 - Enter the code via your web browsers dev tools
- Open your web browser's dev tools ( usually press F12 key / right-click & choose Inspect Element)
- Go to the Console tab
- Paste the following code:
// find the video element (may not work on sites with multiple video elements, but works for most of the main sites) var vid = document.querySelector("video"); // remove the attribute that might stop us from launching the video in PiP vid.removeAttribute("disablePictureInPicture"); // finally, request the PiP vid.requestPictureInPicture();
All being well, you should now have the video pop-out. If not, you may need to tweak document.querySelector("video") to select a specific video element on the page.
Option 2 - Create a Bookmark button to launch PiP
This code is the same as the example in Option 1, but stripped down to one line to one line so it can be executed as a URL.
To use it, simply:
- Select all of the following and drag and drop into your browser's bookmarks bar, or
- Create a new bookmark called PiP and paste the following as the bookmark's URL: javascript: var vid=document.querySelector('video');vid.removeAttribute('disablePictureInPicture');vid.requestPictureInPicture();
- Click the bookmark to launch PiP
How does a "Bookmarklet" work?
A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.
— caseywatts
The magic here, is the addition of javascript to the beginning of the URL. This tells the browser to perform an action on the current page, rather than taking you to a new page.
For more info on bookmarklets and getting more creative with them, see this great explanation from @caseywatts on Making Bookmarklets
...
Original article: https://mothy.dev/posts/free-picture-in-picture
The above is the detailed content of Create your own Picture-In-Picture video feature bookmarklet. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

The article discusses effective JavaScript debugging using browser developer tools, focusing on setting breakpoints, using the console, and analyzing performance.

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

The article explains how to use source maps to debug minified JavaScript by mapping it back to the original code. It discusses enabling source maps, setting breakpoints, and using tools like Chrome DevTools and Webpack.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...
