您需要先安装一个扩展,例如 篡改猴、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; function findVideoElement() { return document.querySelector('video.x1lliihq.x5yr21d.xh8yej3'); } function simulateArrowKey() { const rightArrowEvent = new KeyboardEvent('keydown', { key: 'ArrowRight', code: 'ArrowRight', keyCode: 39, which: 39, bubbles: true, cancelable: true }); document.dispatchEvent(rightArrowEvent); } function cleanup() { if (currentVideo) { currentVideo.removeEventListener('ended', simulateArrowKey); currentVideo.removeEventListener('pause', handlePause); currentVideo.pause(); currentVideo = null; } if (observer) { observer.disconnect(); observer = null; } } function handlePause() { if (currentVideo && !currentVideo.ended) { currentVideo.play(); } } function setupVideoListener() { const video = findVideoElement(); if (video && video !== currentVideo) { cleanup(); currentVideo = video; video.addEventListener('ended', simulateArrowKey); video.addEventListener('pause', handlePause); } } function initObserver() { observer = new MutationObserver(() => { setupVideoListener(); }); observer.observe(document.body, { childList: true, subtree: true }); setupVideoListener(); } // Handle tab visibility changes document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden') { cleanup(); } else { initObserver(); } }); // Handle page unload window.addEventListener('beforeunload', cleanup); // Initial setup initObserver(); })();