Instagram - Enable standard video controls

enable standard video controls

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

Advertisement:

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!)

Advertisement:

// ==UserScript==
// @name                Instagram - Enable standard video controls
// @namespace           https://greasyfork.org/users/821661
// @match               https://www.instagram.com/*
// @grant               GM_getValue
// @grant               GM_setValue
// @run-at              document-start
// @version             1.6
// @author              hdyzen
// @description         enable standard video controls
// @license             GPL-3.0
// ==/UserScript==

const volDesc = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'volume');
const mutedDesc = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'muted');

const append = Node.prototype.appendChild;
const getVolume = () => GM_getValue('volume', 0);

Object.defineProperty(HTMLMediaElement.prototype, 'volume', {
    get: volDesc.get,
    set() { return true; }
});

Object.defineProperty(HTMLMediaElement.prototype, 'muted', {
    get: mutedDesc.get,
    set() { return true; }

});

Node.prototype.appendChild = function (node) {
    const result = append.call(this, node)

    if (node.tagName !== 'VIDEO') return result;

    node.setAttribute('controls', true);
    volDesc.set.call(node, getVolume());

    node.addEventListener("pause", (ev) => ev.stopImmediatePropagation(), true);
    node.addEventListener("play", () => volDesc.set.call(node, GM_getValue('volume', 0)), true);
    node.addEventListener("volumechange", () => GM_setValue('volume', node.volume), true);

    return result;
};

(document.head || document.documentElement).insertAdjacentHTML('beforeend', `
    <style>
        video::-webkit-media-controls {
            display: block !important;
        }
        [data-instancekey]:has([d^="M1.5 13"]) {
            display: none !important;
        }
    </style>`
)