/** * FocusGram Content Hider * Toggleable visibility for: stories tray, feed posts, reels, suggested content. * Flutter controls via window.__fgContent.* * Injected at DOCUMENT_END. * * Key fixes applied: * - Blank-feed fix: hideReels uses DOM removal (not display:none) so layout doesn't collapse * - MutationObserver callback now re-applies CSS AND re-runs all hide functions each cycle * - SPA-heartbeat via window event listener re-applies CSS on pushState/replaceState * - Stories tray detection strengthened for fresh SPA navigations * - Suggested posts detection uses multiple text-node matching strategies */ (function () { 'use strict'; if (window.__fgContent && window.__fgContent.__focusgramReady) { return; } const STYLE_ID = 'fg-content-hider'; let hideStories = false; let hidePosts = false; let hideSuggested = false; let hideReels = false; // ─── CSS rules ───────────────────────────────────────────────────────────── function buildCSS() { const selectors = []; if (hideStories) { selectors.push( '[role="list"]:has([aria-label*="tory"])', '[role="listbox"]:has([aria-label*="tory"])', '[role="menu"] > ul', 'section > div > div:first-child [style*="overflow"]', '[role="list"] [style*="overflow"]', ); } if (hidePosts) { selectors.push( 'body:not([path*="direct"]):not([data-fg-path*="direct"]) article:not([aria-label])', 'body:not([path*="direct"]):not([data-fg-path*="direct"]) [data-pressable-container] > article', ); } // hideReels CSS is intentionally NOT added here. // We use DOM removal instead (see removeReels()) so that room is never left // blank in the feed, and Instagram's infinite-scroll can prove scroll height. return selectors.length ? selectors.join(',\n') + ' { display: none !important; visibility: hidden !important; }' : ''; } function applyCSS() { if (document.body) { document.body.setAttribute('data-fg-path', window.location.pathname || '/'); } let style = document.getElementById(STYLE_ID); if (!style) { style = document.createElement('style'); style.id = STYLE_ID; document.head.appendChild(style); } style.textContent = buildCSS(); } // ─── Story tray JS ───────────────────────────────────────────────────────── function hideStoryTray() { if (!hideStories) return; // Strategy 1: