Remove PrimeVideo X-ray

remove the X-ray panel on Prime Video for uninterrupted viewing pleasure.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Remove PrimeVideo X-ray
// @namespace    http://your.site.com
// @version      1.0
// @description  remove the X-ray panel on Prime Video for uninterrupted viewing pleasure.
// @author       Nilesh Agarwal <[email protected]>
// @match        https://www.primevideo.com/*
// @grant        none
// ==/UserScript==

let xrayVanisherExecuted = false;

function vanishXrayPanel() {
  if (!xrayVanisherExecuted) {
    const style = document.createElement("style");
    style.type = "text/css";
    document.head.appendChild(style);

    const sheet = style.sheet;
    const rule = ".xrayQuickView { visibility: hidden !important; }";

    sheet.insertRule(rule, sheet.cssRules.length);

    xrayVanisherExecuted = true;
  }
}

function observeDOM() {
  const targetNode = document.body;

  const observer = new MutationObserver(mutations => {
    mutations.forEach(mutation => {
      if (mutation.addedNodes && mutation.addedNodes.length > 0) {
        const xrayPanel = document.querySelector(".xrayQuickView");
        if (xrayPanel) {
          vanishXrayPanel();
          observer.disconnect();
        }
      }
    });
  });

  const config = { childList: true, subtree: true };
  observer.observe(targetNode, config);
}

if (document.readyState === "loading") {
  document.addEventListener("DOMContentLoaded", afterLoaded);
} else {
  afterLoaded();
}

function afterLoaded() {
  observeDOM();
}