您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds controls to videos on Instagram.
- // ==UserScript==
- // @name Add Video Controls on Instagram
- // @namespace https://www.instagram.com/
- // @version 1.2
- // @license CC BY-NC-SA 4.0
- // @description Adds controls to videos on Instagram.
- // @author Dan Martí
- // @match *://www.instagram.com/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- function modifyVideo() {
- document.querySelectorAll('video.x1lliihq.x5yr21d.xh8yej3').forEach(video => {
- video.controls = true;
- // Save the mute and volume state before Instagram modifies them
- let prevMuted = video.muted;
- let prevVolume = video.volume;
- // Restore the mute and volume state when interacting with the video
- video.addEventListener('play', () => {
- video.muted = prevMuted;
- video.volume = prevVolume;
- });
- video.addEventListener('seeked', () => {
- video.muted = prevMuted;
- video.volume = prevVolume;
- });
- video.addEventListener('loadeddata', () => {
- video.muted = prevMuted;
- video.volume = prevVolume;
- });
- });
- }
- function removeDiv() {
- document.querySelectorAll('div.x5yr21d.x10l6tqk.x13vifvy.xh8yej3').forEach(div => {
- div.remove();
- });
- }
- // Run at the start and observe changes on the page
- const observer = new MutationObserver(() => {
- modifyVideo();
- removeDiv();
- });
- observer.observe(document.body, { childList: true, subtree: true });
- })();