Hide Instagram Reels and Explore Button

Hide Instagram reels and the explore button from the webpage

  1. // ==UserScript==
  2. // @name Hide Instagram Reels and Explore Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Hide Instagram reels and the explore button from the webpage
  6. // @author AKM777
  7. // @match https://www.instagram.com/*
  8. // @grant none
  9. // ==/UserScript==
  10. // @license MIT
  11. (function () {
  12. 'use strict';
  13.  
  14. // Function to hide reels and explore button
  15. function hideElements() {
  16. // Hide reels in feed
  17. const reelPosts = document.querySelectorAll('article div div div div video'); // Video reels in feed
  18. reelPosts.forEach(el => {
  19. const parent = el.closest('article');
  20. if (parent) parent.style.display = 'none';
  21. });
  22.  
  23. // Hide the "Reels" button
  24. const reelsButtons = document.querySelectorAll('a[href*="/reels/"], div[role="button"][aria-label*="Reels"]');
  25. reelsButtons.forEach(el => {
  26. el.style.display = 'none';
  27. });
  28.  
  29. // Hide the "Explore" button
  30. const exploreButton = document.querySelector('a[href="/explore/"]'); // Explore button in navigation
  31. if (exploreButton) {
  32. exploreButton.style.display = 'none';
  33. }
  34. }
  35.  
  36. // Observe the page for dynamic changes
  37. const observer = new MutationObserver(hideElements);
  38. observer.observe(document.body, { childList: true, subtree: true });
  39.  
  40. // Initial execution
  41. hideElements();
  42. })();