Skip to content

Instantly share code, notes, and snippets.

@jt6562
Created May 24, 2020 14:14
Show Gist options
  • Save jt6562/1e30f53b5bdb275507584641e2785a18 to your computer and use it in GitHub Desktop.
Save jt6562/1e30f53b5bdb275507584641e2785a18 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name EnablePIP
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://*/*
// @match https://*/*
// @run-at document-end
// @grant none
// @require https://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function() {
'use strict';
setTimeout(()=>{
if (document.pictureInPictureElement) return;
let videos = $("video")
if (videos.length == 0) return;
videos.after("<button class='video-ext-btn' style='position:absolute; height:30px; right:0; top:0;'>画中画</button>")
$('.video-ext-btn').click( function(ev) {
let video = $(this).prev()
video.get(0).requestPictureInPicture()
return false;
})
}, 2000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment