Disable Video Popouts

Disable/remove 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.

目前為 2019-11-17 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Disable Video Popouts
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.1
// @license      AGPLv3
// @author       jcunews
// @description  Disable/remove 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 chkParentEle(n) {
    while (n = n.parentNode) {
      if (getComputedStyle(n).position === "fixed") {
        n.remove(n);
        break;
      }
    }
  }

  function chkEle(n) {
    if (n.tagName) {
      if (n.tagName !== "VIDEO") {
        if (n.querySelector('video')) {
          if (getComputedStyle(n).position === "fixed") {
            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});
})();