Greasy Fork

Greasy Fork is available in English.

video fullpage

2024-7-12 18:05:52

当前为 2024-07-12 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);