Instagram enable standard video controls

enable standard video controls

目前為 2024-09-14 提交的版本,檢視 最新版本

// ==UserScript==
// @name               Instagram enable standard video controls
// @namespace          https://gf.qytechs.cn/users/821661
// @match              https://www.instagram.com/*
// @grant              none
// @version            1.1
// @author             hdyzen
// @description        enable standard video controls
// @license            GPL-3.0
// ==/UserScript==
"use strict";

const cantAddControls = () => !(window.location.pathname.startsWith("/stories/") || window.location.pathname.startsWith("/reels/"));

const videosHandler = videosEl => {
    for (const video of videosEl) {
        const videoNextSibling = video.nextElementSibling;
        const poster = videoNextSibling.querySelector("img[src]");

        video.setAttribute("controls", "");

        if (poster) video.setAttribute("poster", poster.src);
        videoNextSibling.style.display = "none";
    }
};

const mutationsHandler = mutations => {
    const videosEl = [...document.querySelectorAll("video[src")].filter(video => !video.hasAttribute("controls"));
    if (videosEl.length && cantAddControls()) {
        videosHandler(videosEl);
    }
};

const observer = new MutationObserver(mutationsHandler);

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址