! Title: Intentional: Facebook (AdGuard) ! Description: Removes Facebook'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 ! ===== Facebook ===== ! Facebook: 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, aria-posinset and data-* attributes. ! --- Algorithmic home feed, when redirects are off --- ! The path regex reads the query: Feeds (?sk=h_chr, any filter) keeps its posts. [$path=/^\\/(?:home\\.php)?(?:\\?(?!(?:.*&)?sk=h_chr(?:&|$)).*)?$/]www.facebook.com##div[role="main"] div[aria-posinset] ! --- Growth injections in feeds: People you may know, suggested groups --- www.facebook.com##div[aria-posinset]:has(a:is([href="/friends/"],[href^="/friends/suggestions"],[href="https://www.facebook.com/friends/"],[href^="https://www.facebook.com/friends/suggestions"])) www.facebook.com##div[aria-posinset]:has(a:is([href^="/groups/discover"],[href^="https://www.facebook.com/groups/discover"])) ! --- Suggested posts (English label) --- www.facebook.com#?#div[aria-posinset]:has(span:contains(/^Suggested for you$/)) ! --- Reels carousels: "Reels and short videos" in feeds, "Related Reels" under videos --- www.facebook.com##div[aria-posinset]:has(div[data-type="hscroll-child"] a[href*="/reel/"]) www.facebook.com##div:has(> div > div[role="region"] div[data-type="hscroll-child"] a[href*="/reel/"]) ! --- Reel player: the opened reel plays, without its previous/next card buttons --- ! In the three-child layout the two outer buttons are navigation in every language. www.facebook.com,m.facebook.com##div:has(> [role="button"]:first-child + div:nth-last-child(2) [data-pagelet="Reels"]) > [role="button"]:is(:first-child, :last-child) ! If more actions share that row, only hide buttons explicitly labelled as card navigation. www.facebook.com,m.facebook.com##div:has(> div [data-pagelet="Reels"]) > div[role="button"]:is([aria-label="Previous Card"], [aria-label="Next Card"]) ! --- Entry points: Video home and its Live, Shows and Explore tabs (a video link keeps working) --- www.facebook.com##a:is([href="/watch/"],[href^="/watch/?"],[href^="/watch/live/"],[href^="/watch/shows/"],[href^="/watch/topic/"],[href="https://www.facebook.com/watch/"],[href^="https://www.facebook.com/watch/?"]):not([href*="?v="],[href*="&v="]) ! --- Entry points: the Reels tab (a reel link keeps working) --- www.facebook.com##a:is([href="/reel/"],[href^="/reel/?"],[href="https://www.facebook.com/reel/"],[href^="https://www.facebook.com/reel/?"]) ! --- Entry points: Gaming home and its video feeds (a streamer's page stays) --- www.facebook.com##a:is([href="/gaming/"],[href^="/gaming/?"],[href^="/gaming/feed/"],[href^="/gaming/video/"],[href="https://www.facebook.com/gaming/"],[href^="https://www.facebook.com/gaming/?"],[href^="https://www.facebook.com/gaming/feed/"],[href^="https://www.facebook.com/gaming/video/"]) ! Facebook: redirects to the intentional view www.facebook.com,m.facebook.com#%#(function(){function g(a,t){for(const f of t){const h=new RegExp(f.from).exec(a);if(!h)continue;const i=f.to.replace(/\$(\d)/g,(p,s)=>h[Number(s)]??"");return i===a?null:i}return null}function v(a,t){const f=a&&new RegExp(a.path),h=e=>{const o=t.document;if(f?.test(t.location.pathname)){const u=a?.viewer;if(!u||u==="*")return o.body;const l=e.closest(u)||Array.from(o.querySelectorAll(u)).find(E=>E.getClientRects().length>0);if(l)return l}if(o.fullscreenElement?.querySelector("video"))return o.fullscreenElement;let n=!1,c=e===o.body||e===o.documentElement?o.elementFromPoint(t.innerWidth/2,t.innerHeight/2):e;for(;c;c=c.parentElement){const u=t.getComputedStyle(c);if(n&&/^(y|block) (mandatory|proximity)$/.test(u.scrollSnapType)&&c.scrollHeight>c.clientHeight)return c;!n&&u.scrollSnapAlign!=="none"&&(c.matches("video")||c.querySelector("video"))&&(n=!0)}return null},i={capture:!0,passive:!1},p=e=>{const o=e.target,n=o instanceof t.Element?o:t.document.body;if(!n)return;const c=h(n),u=c?.querySelector("video")??(c&&c!==t.document.body?c.querySelector("img"):null);if(!c||!u||n.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="slider"]'))return;let l=n;for(;l&&l!==t.document.body;l=l.parentElement)if(l.scrollHeight>l.clientHeight&&/^(auto|scroll)$/.test(t.getComputedStyle(l).overflowY)&&!l.contains(u)){l instanceof t.HTMLElement&&t.getComputedStyle(l).overscrollBehaviorY==="auto"&&(l.style.overscrollBehaviorY="contain"),e.stopImmediatePropagation();return}!c.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)&&p(e)},i),t.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey&&!e.altKey&&["ArrowUp","ArrowDown","PageUp","PageDown"].includes(e.key)&&p(e)},i);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 m=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)&&p(e)}e.type==="touchend"&&(s=void 0)};t.addEventListener("touchmove",m,i),t.addEventListener("touchend",m,i),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)&&p(e),e.type==="pointerup"&&(r=void 0)};t.addEventListener("pointermove",d,i),t.addEventListener("pointerup",d,i),t.addEventListener("pointercancel",()=>{r=void 0},!0)}function b(a,t){v(a.singleVideo,t);const f=t.document;let h=0,i=!1;const p=()=>{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=()=>{i=!1;const r=t.location.pathname+t.location.search,d=g(r,a.redirects);if(d!==null){p()&&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-h>1e3&&(h=n,o.click())}},m=()=>{i||(i=!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(m).observe(f,{childList:!0,subtree:!0}),t.setInterval(s,1e3),s()}var y={"www.facebook.com":{singleVideo:{path:"^/reels?/[0-9]+/?$"},redirects:[{from:"^/(?:home\\.php)?(?:\\?(?!(?:.*&)?sk=h_chr(?:&|$)).*)?$",to:"/?filter=all&sk=h_chr"},{from:"^/watch(?:/(?:live|shows|topic))?/?(?:\\?(?!(?:.*&)?v=).*)?$",to:"/?filter=all&sk=h_chr"},{from:"^/reels?/?(?:\\?.*)?$",to:"/?filter=all&sk=h_chr"},{from:"^/gaming(?:/?|/(?:feed|video|browse|live)(?:/.*)?)(?:\\?.*)?$",to:"/?filter=all&sk=h_chr"}],select:[]},"m.facebook.com":{singleVideo:{path:"^/reels?/[0-9]+/?$"},redirects:[],select:[]}}[location.hostname];y&&b(y,window)})();