StudyGo 30 second preview bypass

Opens StudyGo videos with controls enabled in a new tab

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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
  });
})();