全网站视频画中画模式

使用画中画模式观看视频,适合谷歌70以上版本

  1. // ==UserScript==
  2. // @icon
  3. // @name 全网站视频画中画模式
  4. // @namespace HZH
  5. // @author LL99LL
  6. // @description 使用画中画模式观看视频,适合谷歌70以上版本
  7. // @match *
  8. // @include *
  9. // @require http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js
  10. // @version 0.1.1
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. let video=null
  16. $(function () {
  17. //查找video
  18. let findVideo=function(DOM=document.body){
  19. video = DOM.querySelector("video")
  20. if (video){
  21. loadButton(video)
  22. return
  23. }
  24. DOM.querySelectorAll("iframe").forEach(function(iframe){
  25. console.log(iframe)
  26. console.log(iframe.contentWindow)
  27. iframe.contentWindow.onload = function() {
  28. findVideo(iframe.contentDocument.body)
  29. }
  30. })
  31.  
  32. }
  33. let loadButton=function(){
  34. let button = '<button id="HZHBtn" title="画中画" draggable="true" style="cursor:pointer;opacity:0.5;width:20px;height:20px;border-radius:10px;position: fixed;top: 5px;left: 5px;z-index: 10000; border: 5px solid #888; padding: 0;"></button>';
  35. let body = $("body");
  36. if (body) {
  37. body.append(button);
  38. $('#HZHBtn').hover(function(){
  39. $('#HZHBtn').css('opacity','1')
  40. },function(){
  41. $('#HZHBtn').css('opacity','0.5')
  42. })
  43. }
  44. }
  45.  
  46. findVideo()
  47. $("#HZHBtn").click(function () {
  48. //获取播放器(video)对象
  49. var btn=$('#HZHBtn')[0]
  50. if (video !== document.pictureInPictureElement) {
  51. // 尝试进入画中画模式
  52. video.requestPictureInPicture();
  53. } else {
  54. // 退出画中画
  55. document.exitPictureInPicture();
  56. }
  57. });
  58. });
  59.  
  60. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址