! Title: Intentional: Twitch (AdGuard) ! Description: Removes Twitch'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 ! ===== Twitch ===== ! Twitch: see site.yaml for the policy and tests.yaml for what each rule must do. ! --- Front page: featured carousel and recommendation shelves (redirects to Following) --- www.twitch.tv##[data-a-target="front-page-carousel"] www.twitch.tv##[data-a-target="front-page-main-content"] ! --- Browse: entry point (Browse redirects to Following) --- www.twitch.tv##a[data-a-target="browse-link"] ! --- Side navigation: recommendation sections; Followed Channels stays --- ! Each section is a `.side-nav-section`; its cards say where they come from in data-test-selector. www.twitch.tv##.side-nav-section:has(a[data-test-selector="recommended-channel"]) www.twitch.tv##.side-nav-section:has(a[data-test-selector="recommended-collab-channel"]) www.twitch.tv##.side-nav-section:has(a[data-test-selector="popular-channel"]) www.twitch.tv##.side-nav-section:has(a[data-test-selector="similarity-channel"]) www.twitch.tv##.side-nav-section:has([data-test-selector="category"]) ! --- Following page: the "Recommended channels" shelf --- ! Recommendation shelves render as `.find-me` with shelf cards; followed live channels use other cards. www.twitch.tv##.find-me:has([data-test-selector="shelf-card-selector"]) ! --- Mobile site: the Live tab, the Browse entry and the front page feed --- m.twitch.tv##li[role="presentation"]:has(> a[role="tab"][href="/"]) m.twitch.tv##a[href="/directory"] [$path=/^\\/(\\?|$)/]m.twitch.tv###page-main-content-wrapper ! --- Shared clip: remove the clip shelf, keep the channel's own Clips library --- [$path=/^\\/\[^/\]+\\/clip\\//]www.twitch.tv##.channel-info-content div:has(> .tw-tower > [data-a-target^="clips-card-"]) ! Mobile puts the current clip's details first, then links to more clips. [$path=/^\\/(?:\[^/\]+\\/)?clip\\//]m.twitch.tv##[class*="secondaryContent--"] > div:has(> a[href*="/clip/"]) ~ div:has(> a[href*="/clip/"]) ! Twitch: redirects to the intentional view www.twitch.tv,m.twitch.tv#%#(function(){function g(a,t){for(const f of t){const p=new RegExp(f.from).exec(a);if(!p)continue;const s=f.to.replace(/\$(\d)/g,(m,l)=>p[Number(l)]??"");return s===a?null:s}return null}function v(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(b=>b.getClientRects().length>0);if(i)return i}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},s={capture:!0,passive:!1},m=e=>{const o=e.target,n=o instanceof t.Element?o:t.document.body;if(!n)return;const c=p(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 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}!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)&&m(e)},s),t.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey&&!e.altKey&&["ArrowUp","ArrowDown","PageUp","PageDown"].includes(e.key)&&m(e)},s);let l;t.addEventListener("touchstart",e=>{const o=e.touches[0];l=o&&e.touches.length===1?{x:o.clientX,y:o.clientY}:void 0},{capture:!0,passive:!0});const y=e=>{const o=e.changedTouches[0];if(l&&o&&e.touches.length<=1){const n=Math.abs(o.clientY-l.y);n>8&&n>Math.abs(o.clientX-l.x)&&m(e)}e.type==="touchend"&&(l=void 0)};t.addEventListener("touchmove",y,s),t.addEventListener("touchend",y,s),t.addEventListener("touchcancel",()=>{l=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,s),t.addEventListener("pointerup",d,s),t.addEventListener("pointercancel",()=>{r=void 0},!0)}function E(a,t){v(a.singleVideo,t);const f=t.document;let p=0,s=!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},l=()=>{s=!1;const r=t.location.pathname+t.location.search,d=g(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())}},y=()=>{s||(s=!0,t.setTimeout(l,50))};for(const r of["pushState","replaceState"]){const d=t.history[r];t.history[r]=function(...e){const o=d.apply(this,e);return l(),o}}t.addEventListener("popstate",l),a.select.length>0&&new t.MutationObserver(y).observe(f,{childList:!0,subtree:!0}),t.setInterval(l,1e3),l()}var h={"www.twitch.tv":{redirects:[{from:"^/(\\?.*)?$",to:"/directory/following"},{from:"^/directory/?(\\?.*)?$",to:"/directory/following"},{from:"^/directory/(all|gaming|irl|music|creative|esports)/?(\\?.*)?$",to:"/directory/following"}],select:[]},"m.twitch.tv":{redirects:[{from:"^/(\\?.*)?$",to:"/directory/following"},{from:"^/directory/?(\\?.*)?$",to:"/directory/following"},{from:"^/directory/(all|gaming|irl|music|creative|esports)/?(\\?.*)?$",to:"/directory/following"}],select:[]}}[location.hostname];h&&E(h,window)})();