vigorboi / Douyu fullscreen video

// ==UserScript==
// @name         Douyu fullscreen video
// @namespace    douyu-fullscreen-video
// @version      1.0
// @description  Set the fullscreen attribute on the video element in the Douyu player
// @match        https://v.douyu.com/show/*
// @run-at       document-end
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  'use strict';

  // Wait for the page to load
  window.addEventListener('load', function () {

    // Wait for 5 seconds
    setTimeout(function () {

      // Get the demand-video element and its shadow root
      const element = document.querySelector("body > demand-video-app > main > div.layout-Main > div > demand-video");
      if (!element) {
        console.log("Cannot find demand-video element");
        return;
      }
      const shadowRoot = element.shadowRoot;
      if (!shadowRoot) {
        console.log("Cannot access shadow root of demand-video element");
        return;
      }

      // Find the first div element in the shadow root and set its fullscreen attribute to true
      var div = shadowRoot.querySelector("div");
      if (div) {
        console.log("Setting fullscreen attribute on div element");
        div.setAttribute('fullscreen', 'true');
      }
      else {
        console.log("Cannot find div element in shadow root");
      }

    }, 5000);

  });

})();