Disable Video Popouts

Disable/remove non browser native video overlays on web pages. This script applies on all sites by default, and must be manually configured to exclude specific sites. Note: this is a somewhat aggresive blocker, where it may break site functionality.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Disable Video Popouts
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.3
// @license      AGPLv3
// @author       jcunews
// @description  Disable/remove non browser native video overlays on web pages. This script applies on all sites by default, and must be manually configured to exclude specific sites. Note: this is a somewhat aggresive blocker, where it may break site functionality.
// @match        *://*/*
// @exclude      *://dont-block.this.com/*
// @grant        none
// ==/UserScript==

(() => {
  var ans = ["class", "style"];

  function getStyle(e, z) {
    try {
      return getComputedStyle(e)
    } catch(z) {
      return null
    }
  }

  function chkStyle(n, s) {
    return (s = getStyle(n)) && (s.position === "fixed") && (s.left !== "0px") && (s.top !== "0px") && (s.right !== "0px") && (s.bottom !== "0px");
  }

  function chkParentEle(n, s) {
    while (n = n.parentNode) {
      if (chkStyle(n)) {
        n.remove(n);
        break;
      }
    }
  }

  function chkEle(n, s) {
    if (n.tagName) {
      if (n.tagName !== "VIDEO") {
        if (n.querySelector('video')) {
          if (chkStyle(n)) {
            n.remove(n);
          } else chkParentEle(n);
        }
      } else chkParentEle(n);
    }
  }

  (new MutationObserver(recs => {
    recs.forEach((r, i) => {
      r.addedNodes.forEach((n) => chkEle(n));
      if (ans.includes(r.attributeName)) chkEle(r.target);
    });
  })).observe(document, {attributes: true, childList: true, subtree: true});
})();