StudyGo 30 second preview bypass

Opens StudyGo videos with controls enabled in a new tab

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         StudyGo 30 second preview bypass
// @name:nl      StudyGo 30 seconden-preview bypasser
// @license      MIT
// @namespace    https://greasyfork.org/nl/users/1552919-dandandev
// @version      1.0.1
// @description  Opens StudyGo videos with controls enabled in a new tab
// @description:nl Opent StudyGo videos met controls aan in een nieuw tabblad
// @match        https://studygo.com/*
// @match        https://www.studygo.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(() => {
  'use strict';

  const VIMEO_HOST = "player.vimeo.com";

  function handleVimeoIframe(iframe) {
    if (!iframe.src || !iframe.src.includes(VIMEO_HOST)) return;
    window.open(iframe.src.replace("controls=0", "controls=1"), "_blank");
    document.querySelector(".media-modal-close-btn")?.click();
  }

  const observer = new MutationObserver(mutations => {
    for (const mutation of mutations) {
      for (const node of mutation.addedNodes) {
        if (node.nodeType !== Node.ELEMENT_NODE) continue;
        if (node.tagName === "IFRAME") handleVimeoIframe(node);
        node.querySelectorAll?.("iframe").forEach(handleVimeoIframe);
      }
    }
  });

  observer.observe(document.body, {
    childList: true,
    subtree: true
  });
})();