video fullpage

2024-7-12 18:05:52

目前为 2024-07-12 提交的版本。查看 最新版本

// ==UserScript==
// @name        video fullpage
// @namespace   github.q962
// @match       https://*/*
// @version     1.1
// @author      q962
// @grant       GM_registerMenuCommand
// @grant       GM_addStyle
// @license     MIT

// @description 2024-7-12 18:05:52
// ==/UserScript==

let global_css = `
.___fullpage{
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 999999999 !important;
  position: fixed !important;
  background: black !important;
  display: block;
}

.___fix > *{
  display: none;
}
`;

GM_addStyle(global_css);

/////////////////////////////////////////////////////////

const all_video_elems = [];

let current_video_parent_elemt = null;
let current_video_elemt = null;
let current_video_next_elemt = null;

function set_fullpage(){

  if(!current_video_elemt)return;

  if(current_video_elemt.classList.contains("___fullpage")){
      current_video_elemt.classList.remove("___fullpage");

      document.body.classList.remove("___fix");

      current_video_parent_elemt.insertBefore(current_video_elemt, current_video_next_elemt);
  }else{
      current_video_elemt.classList.add("___fullpage");

      document.body.classList.add("___fix");

      document.body.append(current_video_elemt);
  }
}

GM_registerMenuCommand('全页', set_fullpage);


function bind_evnet(elem){
  elem.addEventListener('play', function (e) {
    current_video_elemt = e.target;
    current_video_parent_elemt = current_video_elemt.parentElement;
    current_video_next_elemt = current_video_elemt.nextSibling;
  })

  elem.addEventListener('pause', function (e) {
  });
}

function findingVideoElem(){

  let video_elems = document.querySelectorAll("video");

  for( let index=0; index < video_elems.length; index++){
    let video_elem = video_elems[index];

    if( !( video_elem in all_video_elems )) {
      bind_evnet( video_elem );
      all_video_elems.push( video_elem );
    }
  }
}

setInterval(findingVideoElem, 2000);

QingJ © 2025

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