! Title: Intentional: Instagram (AdGuard) ! Description: Removes Instagram's algorithmic feeds and infinite scrolling, so you only see what you came for. ! Homepage: https://aymericbeaumet.github.io/intentional/ ! License: MIT ! Version: 0.2.0 ! Expires: 1 day ! Redirects need this list to be added as Trusted ! ===== Instagram ===== ! Instagram: see site.yaml for the policy and tests.yaml for what each rule must do. ! Class names are generated and change constantly: rules anchor on href, role and structure. ! --- Entry points: Explore and the Reels feed (a profile's own Reels tab stays) --- www.instagram.com##a[href="/explore/"] www.instagram.com##a[href="/reels/"] ! --- "For you" home feed, when redirects are off --- ! The path regex reads the query: /?variant=following and /?variant=favorites keep their posts. [$path=/^\\/(?:\\?(?!(?:.*&)?variant=(?:following|favorites)(?:&|$)).*)?$/]www.instagram.com##main article ! --- Suggested posts and reels mixed into feeds (English labels) --- www.instagram.com#?#article:has(span:contains(/^Suggested (?:for you|posts|reels|threads)$/)) ! --- Suggested accounts: sidebar and feed carousels ("See all" leads to /explore/people/), profiles --- www.instagram.com##div:has(> div > a[href^="/explore/people/"]) www.instagram.com##div:has(> div > a[href$="/related_profiles/"]) ! --- Explore grid, when redirects are off (the search box above it stays) --- [$path=/^\\/explore\\/?(?:\\?.*)?$/]www.instagram.com##main a:is([href*="/p/"],[href*="/reel/"]) ! --- Reels feed, when redirects are off: the opened reel plays, the next ones and the up/down buttons are gone --- [$path=/^\\/(?:\[\\w.\]+\\/)?reels?(?:\\/|$)/]www.instagram.com##main:has(> div[aria-busy][tabindex] video) > div[role="toolbar"] [$path=/^\\/(?:\[\\w.\]+\\/)?reels?(?:\\/|$)/]www.instagram.com##main:has(> div[role="toolbar"]) > div[aria-busy][tabindex] > div:not([role="dialog"], [role="complementary"]):has(video) ~ div:not([role="dialog"], [role="complementary"]):has(video) ! The phone viewer stacks transformed cards below its header and has no toolbar. [$path=/^\\/(?:\[\\w.\]+\\/)?reels?\\/\[\\w-\]+\\/?(?:\\?|$)/]www.instagram.com#$#header + div > div:has(> div[style*="transform-origin"] video) { overflow-y: clip !important } ! Instagram: redirects to the intentional view www.instagram.com#%#(function(){function v(a,t){for(const f of t){const p=new RegExp(f.from).exec(a);if(!p)continue;const c=f.to.replace(/\$(\d)/g,(m,s)=>p[Number(s)]??"");return c===a?null:c}return null}function g(a,t){const f=a&&new RegExp(a.path),p=e=>{const o=t.document;if(f?.test(t.location.pathname)){const u=a?.viewer;if(!u||u==="*")return o.body;const i=e.closest(u)||Array.from(o.querySelectorAll(u)).find(E=>E.getClientRects().length>0);if(i)return i}if(o.fullscreenElement?.querySelector("video"))return o.fullscreenElement;let n=!1,l=e===o.body||e===o.documentElement?o.elementFromPoint(t.innerWidth/2,t.innerHeight/2):e;for(;l;l=l.parentElement){const u=t.getComputedStyle(l);if(n&&/^(y|block) (mandatory|proximity)$/.test(u.scrollSnapType)&&l.scrollHeight>l.clientHeight)return l;!n&&u.scrollSnapAlign!=="none"&&(l.matches("video")||l.querySelector("video"))&&(n=!0)}return null},c={capture:!0,passive:!1},m=e=>{const o=e.target,n=o instanceof t.Element?o:t.document.body;if(!n)return;const l=p(n),u=l?.querySelector("video")??(l&&l!==t.document.body?l.querySelector("img"):null);if(!l||!u||n.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="slider"]'))return;let i=n;for(;i&&i!==t.document.body;i=i.parentElement)if(i.scrollHeight>i.clientHeight&&/^(auto|scroll)$/.test(t.getComputedStyle(i).overflowY)&&!i.contains(u)){i instanceof t.HTMLElement&&t.getComputedStyle(i).overscrollBehaviorY==="auto"&&(i.style.overscrollBehaviorY="contain"),e.stopImmediatePropagation();return}!l.contains(n)&&n!==t.document.body&&n!==t.document.documentElement||(e.preventDefault(),e.stopImmediatePropagation())};t.addEventListener("wheel",e=>{!e.ctrlKey&&Math.abs(e.deltaY)>Math.abs(e.deltaX)&&m(e)},c),t.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey&&!e.altKey&&["ArrowUp","ArrowDown","PageUp","PageDown"].includes(e.key)&&m(e)},c);let s;t.addEventListener("touchstart",e=>{const o=e.touches[0];s=o&&e.touches.length===1?{x:o.clientX,y:o.clientY}:void 0},{capture:!0,passive:!0});const h=e=>{const o=e.changedTouches[0];if(s&&o&&e.touches.length<=1){const n=Math.abs(o.clientY-s.y);n>8&&n>Math.abs(o.clientX-s.x)&&m(e)}e.type==="touchend"&&(s=void 0)};t.addEventListener("touchmove",h,c),t.addEventListener("touchend",h,c),t.addEventListener("touchcancel",()=>{s=void 0},!0);let r;t.addEventListener("pointerdown",e=>{r=e.pointerType==="touch"&&e.isPrimary?{id:e.pointerId,x:e.clientX,y:e.clientY}:void 0},!0);const d=e=>{if(!r||r.id!==e.pointerId)return;const o=Math.abs(e.clientY-r.y);o>8&&o>Math.abs(e.clientX-r.x)&&m(e),e.type==="pointerup"&&(r=void 0)};t.addEventListener("pointermove",d,c),t.addEventListener("pointerup",d,c),t.addEventListener("pointercancel",()=>{r=void 0},!0)}function b(a,t){g(a.singleVideo,t);const f=t.document;let p=0,c=!1;const m=()=>{try{const r="intentional:redirects",d=Date.now(),e=JSON.parse(t.sessionStorage.getItem(r)||"[]").filter(o=>d-o<1e4);if(e.length>=3)return!1;e.push(d),t.sessionStorage.setItem(r,JSON.stringify(e))}catch{}return!0},s=()=>{c=!1;const r=t.location.pathname+t.location.search,d=v(r,a.redirects);if(d!==null){m()&&t.location.replace(d);return}for(const e of a.select){if(!new RegExp(e.when).test(r)||f.querySelector(e.selected))continue;const o=f.querySelector(e.click),n=Date.now();o instanceof t.HTMLElement&&n-p>1e3&&(p=n,o.click())}},h=()=>{c||(c=!0,t.setTimeout(s,50))};for(const r of["pushState","replaceState"]){const d=t.history[r];t.history[r]=function(...e){const o=d.apply(this,e);return s(),o}}t.addEventListener("popstate",s),a.select.length>0&&new t.MutationObserver(h).observe(f,{childList:!0,subtree:!0}),t.setInterval(s,1e3),s()}var y={"www.instagram.com":{singleVideo:{path:"^/(?:[\\w.]+/)?reels?/[\\w-]+/?$",viewer:'main:has(> div[role="toolbar"]) > div[aria-busy][tabindex]:has(video), header + div > div:has(> div[style*="transform-origin"] video)'},redirects:[{from:"^/(?:\\?(?!(?:.*&)?variant=(?:following|favorites)(?:&|$)).*)?$",to:"/?variant=following"},{from:"^/explore(?:/(?:people/(?:suggested/)?)?)?(?:\\?.*)?$",to:"/?variant=following"},{from:"^/reels/?(?:\\?.*)?$",to:"/?variant=following"},{from:"^/reels/([A-Za-z0-9_-]+)/?\\?(?:[^&]*&)*comment_id=([0-9]+)(?:&|$)",to:"/reel/$1/?comment_id=$2"},{from:"^/reels/([A-Za-z0-9_-]+)/?(?:\\?.*)?$",to:"/reel/$1/"},{from:"^/popular/?(?:\\?.*)?$",to:"/?variant=following"}],select:[]}}[location.hostname];y&&b(y,window)})();