Created
February 28, 2026 15:13
-
-
Save macedonga/a45ebf3b147ed621b364fe8416a78c57 to your computer and use it in GitHub Desktop.
Keyboard shortcuts for Instagram Reels on desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Brainrotmaxxing for Instagram Reels | |
| // @namespace http://tampermonkey.net/ | |
| // @version 5.0.0 | |
| // @match https://www.instagram.com/* | |
| // @grant none | |
| // @description Keyboard shortcuts for Instagram Reels: L to like/unlike, S to save/remove, C to open comments, P to play/pause, I/K to navigate reels. | |
| // @author Marco Ceccon (@macedonga) | |
| // ==/UserScript== | |
| (function () { | |
| "use strict"; | |
| function getMostVisibleVideo() { | |
| const videos = document.querySelectorAll("video"); | |
| let best = null; | |
| let bestScore = 0; | |
| videos.forEach(video => { | |
| const rect = video.getBoundingClientRect(); | |
| const vh = window.innerHeight; | |
| const visible = | |
| Math.min(rect.bottom, vh) - Math.max(rect.top, 0); | |
| const score = Math.max(0, visible); | |
| if (score > bestScore) { | |
| bestScore = score; | |
| best = video; | |
| } | |
| }); | |
| return best; | |
| } | |
| function getReelRoot(video) { | |
| if (!video) return null; | |
| let el = video.parentElement; | |
| while (el && el !== document.body) { | |
| const hasVideo = el.querySelector("video"); | |
| const hasAction = | |
| el.querySelector('svg[aria-label="Like"]') || | |
| el.querySelector('svg[aria-label="Unlike"]') || | |
| el.querySelector('svg[aria-label="Save"]') || | |
| el.querySelector('svg[aria-label="Remove"]'); | |
| if (hasVideo && hasAction) { | |
| return el; | |
| } | |
| el = el.parentElement; | |
| } | |
| return null; | |
| } | |
| function clickSvgByAria(root, label) { | |
| if (!root) return; | |
| let labels; | |
| if (label === "Like") { | |
| labels = ["Like", "Unlike"]; | |
| } else if (label === "Save") { | |
| labels = ["Save", "Remove"]; | |
| } else { | |
| labels = [label]; | |
| } | |
| for (const lbl of labels) { | |
| const svg = root.querySelector(`svg[aria-label="${lbl}"]`); | |
| if (svg) { | |
| const btn = svg.closest('[role="button"]'); | |
| if (btn) btn.click(); | |
| break; | |
| } | |
| } | |
| } | |
| function togglePlay(video) { | |
| if (!video) return; | |
| video.paused ? video.play() : video.pause(); | |
| } | |
| function scrollReel(direction = "next") { | |
| const selector = | |
| direction === "next" | |
| ? '[aria-label="Navigate to next reel"]' | |
| : '[aria-label="Navigate to previous reel"]'; | |
| const btn = document.querySelector(selector); | |
| if (btn) btn.click(); | |
| } | |
| document.addEventListener("keydown", e => { | |
| if ( | |
| document.activeElement.tagName === "INPUT" || | |
| document.activeElement.tagName === "TEXTAREA" || | |
| document.activeElement.isContentEditable | |
| ) return; | |
| const video = getMostVisibleVideo(); | |
| const root = getReelRoot(video); | |
| switch (e.key.toLowerCase()) { | |
| case "l": | |
| clickSvgByAria(root, "Like"); | |
| break; | |
| case "s": | |
| clickSvgByAria(root, "Save"); | |
| break; | |
| case "c": | |
| clickSvgByAria(root, "Comment"); | |
| break; | |
| case "p": | |
| togglePlay(video); | |
| break; | |
| case "i": | |
| scrollReel("prev"); | |
| break; | |
| case "k": | |
| scrollReel("next"); | |
| break; | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment