NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name instagram enable image context menu // @namespace http://tampermonkey.net/ // @version 0.6 // @description this script will enable the context menu on images/videos // @author Larvata // @license MIT // @match https://www.instagram.com/* // @grant none // ==/UserScript== (function() { 'use strict'; const hook = (el) => { setTimeout(() => { const images = el.querySelectorAll('img[srcset]'); const videos = el.querySelectorAll('video'); if (images.length) { images.forEach((img) => { img.removeAttribute('srcset'); img.parentElement.nextElementSibling.remove(); }) } if (videos.length) { videos.forEach((vid) => { vid.style.zIndex = 1; const attribute = document.createAttribute('controls'); vid.setAttributeNode(attribute); }) } }, 100); } const start = () => { const firstArticle = document.querySelector('article[role=presentation]'); if (!firstArticle) { setTimeout(start, 1000*1); return; } console.log('started.') const articleContainer = firstArticle.parentElement; const firstLoadArticles = document.querySelectorAll('article[role=presentation]'); firstLoadArticles.forEach(hook); const config = { attributes: true, childList: true, subtree: true, }; const observer = new MutationObserver((mutationsList, observer) => { mutationsList.forEach((mutations) => { const { addedNodes } = mutations; if (!addedNodes) { return; } addedNodes.forEach(hook); }) }); observer.observe(articleContainer, config); } start(); })();