您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Auto-plays next reel when your on the reels page on someone's profile!
当前为
// ==UserScript== // @name Instagram Video Autoplay Controller // @namespace http://tampermonkey.net/ // @icon https://www.google.com/s2/favicons?sz=64&domain=instagram.com // @version 1.0 // @description Auto-plays next reel when your on the reels page on someone's profile! // @author YourName // @match *://*.instagram.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; let currentVideo = null; let observer = null; let isTabActive = document.visibilityState === 'visible'; function findVideoElement() { return document.querySelector('video.x1lliihq.x5yr21d.xh8yej3'); } function simulateArrowKey() { if (!isTabActive) return; // Only act if tab is active const rightArrowEvent = new KeyboardEvent('keydown', { key: 'ArrowRight', code: 'ArrowRight', keyCode: 39, which: 39, bubbles: true, cancelable: true }); document.dispatchEvent(rightArrowEvent); } function setupVideoListener() { const video = findVideoElement(); if (video && video !== currentVideo) { currentVideo = video; video.addEventListener('ended', simulateArrowKey); video.addEventListener('pause', () => { if (!isTabActive) return; // Only act if tab is active if (!video.ended) video.play(); }); } } function initObserver() { observer = new MutationObserver(() => { if (!findVideoElement()) return; setupVideoListener(); }); observer.observe(document.body, { childList: true, subtree: true }); } // Handle tab visibility changes document.addEventListener('visibilitychange', () => { isTabActive = document.visibilityState === 'visible'; if (isTabActive) { // Re-initialize when tab becomes active initObserver(); setupVideoListener(); } else { // Cleanup when tab becomes inactive if (observer) { observer.disconnect(); observer = null; } } }); // Initial setup if tab is active if (isTabActive) { initObserver(); setupVideoListener(); } // Handle navigation changes (back/forward) window.addEventListener('popstate', () => { if (isTabActive) { if (observer) observer.disconnect(); initObserver(); } }); })();