hide twitter video controls (until hover)

6/3/2024, 1:04:59 AM

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        hide twitter video controls (until hover)
// @namespace   Violentmonkey Scripts
// @match       https://x.com/*
// @grant       none
// @version     1.0
// @author      minnieo
// @description 6/3/2024, 1:04:59 AM
// @license     MIT
// ==/UserScript==



document.addEventListener("DOMContentLoaded", () => {
  const videoControls = document.querySelector('div[data-testid="videoComponent"] div.css-175oi2r.r-18u37iz.r-n7gxbd');
  videoControls.style.display = 'none';

  if (videoControls) { // Check if videoControls exists
    // Show controls when the mouse enters the area
    videoControls.addEventListener('mouseenter', () => {
      videoControls.style.display = 'block';
    });

    // Hide controls when the mouse leaves the area
    videoControls.addEventListener('mouseout', () => {
      videoControls.style.display = 'none';
    });
  } else {
    console.error('Video controls element not found.');
  }
});