Created
October 25, 2025 20:11
-
-
Save tire-fire/84a48b595ea9667ff3899f3b1bec3b0f to your computer and use it in GitHub Desktop.
Right-click save instagram image
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 Instagram Right-Click Save | |
| // @namespace http://tampermonkey.net/ | |
| // @version 4.4 | |
| // @description Enable native right-click save on Instagram images | |
| // @match https://www.instagram.com/* | |
| // @grant none | |
| // @run-at document-start | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| console.log('Instagram Right-Click Save initializing...'); | |
| const originalAddEventListener = EventTarget.prototype.addEventListener; | |
| EventTarget.prototype.addEventListener = function(type, listener, options) { | |
| if (type === 'contextmenu') { | |
| return; | |
| } | |
| return originalAddEventListener.call(this, type, listener, options); | |
| }; | |
| const processedSrcs = new Set(); | |
| function enableImageRightClick() { | |
| const images = document.querySelectorAll('img.x5yr21d, img[src*="cdninstagram"]'); | |
| let processed = 0; | |
| for (const img of images) { | |
| if (!img.src || processedSrcs.has(img.src)) continue; | |
| if (processed >= 20) break; | |
| const parent = img.parentElement; | |
| if (!parent) continue; | |
| if (parent.querySelector('.instagram-save-overlay')) continue; | |
| img.style.pointerEvents = 'auto'; | |
| img.draggable = true; | |
| const overlay = document.createElement('div'); | |
| overlay.className = 'instagram-save-overlay'; | |
| overlay.style.cssText = ` | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| z-index: 999; | |
| pointer-events: auto; | |
| cursor: context-menu; | |
| `; | |
| const overlayImg = document.createElement('img'); | |
| overlayImg.src = img.src; | |
| overlayImg.crossOrigin = 'anonymous'; | |
| overlayImg.style.cssText = ` | |
| width: 100%; | |
| height: 100%; | |
| object-fit: cover; | |
| pointer-events: auto; | |
| `; | |
| overlay.appendChild(overlayImg); | |
| if (parent.style.position !== 'relative' && parent.style.position !== 'absolute') { | |
| parent.style.position = 'relative'; | |
| } | |
| parent.appendChild(overlay); | |
| processedSrcs.add(img.src); | |
| processed++; | |
| } | |
| if (processed > 0) { | |
| console.log(`Added overlays to ${processed} images (total tracked: ${processedSrcs.size})`); | |
| } | |
| } | |
| let debounceTimer; | |
| let isProcessing = false; | |
| const observer = new MutationObserver(() => { | |
| if (isProcessing) return; | |
| clearTimeout(debounceTimer); | |
| debounceTimer = setTimeout(() => { | |
| isProcessing = true; | |
| enableImageRightClick(); | |
| isProcessing = false; | |
| }, 300); | |
| }); | |
| function init() { | |
| console.log('Instagram Right-Click Save initialized'); | |
| enableImageRightClick(); | |
| if (document.body) { | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| } | |
| } | |
| if (document.readyState === 'loading') { | |
| document.addEventListener('DOMContentLoaded', init); | |
| } else { | |
| init(); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Talk about light weight... this is great. Thanks!!
I also like this one too - https://greasyfork.org/en/scripts/521062-instagram-working-progress-bar/code
I pushed this through bot and it works if you want something half the lines: