! Title: Intentional: YouTube (AdGuard) ! Description: Removes YouTube'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 ! ===== YouTube ===== ! YouTube: see site.yaml for the policy and tests.yaml for what each rule must do. ! --- Home feed --- ! page-subtype follows in-app navigation, so this keeps working after clicks. www.youtube.com##ytd-browse[page-subtype="home"] www.youtube.com##ytd-guide-entry-renderer:has(a[href="/"]) www.youtube.com##ytd-mini-guide-entry-renderer:has(a[href="/"]) m.youtube.com##div[tab-identifier="FEwhat_to_watch"] m.youtube.com##ytm-pivot-bar-item-renderer:has(.pivot-w2w) ! --- Explore / Trending --- www.youtube.com##ytd-browse[page-subtype="trending"] ! --- Shorts: entry points --- www.youtube.com##ytd-guide-entry-renderer:has(a[title="Shorts"]) www.youtube.com##ytd-mini-guide-entry-renderer[aria-label="Shorts"] www.youtube.com##yt-tab-shape[tab-title="Shorts"] www.youtube.com#?#yt-chip-cloud-chip-renderer:contains(/^\s*Shorts\s*$/) m.youtube.com##ytm-pivot-bar-item-renderer:has(.pivot-shorts) ! --- Shorts: shelves and tiles (home, subscriptions, search, channels) --- www.youtube.com##ytd-reel-shelf-renderer www.youtube.com##ytd-rich-section-renderer:has(ytd-rich-shelf-renderer[is-shorts]) www.youtube.com##grid-shelf-view-model:has(a[href^="/shorts/"]) www.youtube.com##ytd-rich-item-renderer:has(a[href^="/shorts/"]) www.youtube.com##ytd-video-renderer:has(a[href^="/shorts/"]) www.youtube.com##ytd-grid-video-renderer:has(a[href^="/shorts/"]) www.youtube.com##yt-lockup-view-model:has(a[href^="/shorts/"]) m.youtube.com##ytm-reel-shelf-renderer m.youtube.com##ytm-shorts-lockup-view-model m.youtube.com##ytm-shorts-lockup-view-model-v2 m.youtube.com##ytm-rich-item-renderer:has(a[href^="/shorts/"]) m.youtube.com##ytm-video-with-context-renderer:has(a[href^="/shorts/"]) ! --- Shorts player: one Short, no next one --- ! YouTube embeds the first queue in the page, then fetches later batches separately. www.youtube.com,m.youtube.com#%#//scriptlet('ubo-set-constant', 'ytInitialReelWatchSequenceResponse', 'undefined') ||youtube.com/youtubei/v1/reel/reel_watch_sequence$xmlhttprequest,~third-party ! Desktop can also scroll cards that were already rendered before the list applied. www.youtube.com#$#ytd-shorts #shorts-container { overflow: clip !important } www.youtube.com##ytd-shorts #navigation-button-up www.youtube.com##ytd-shorts #navigation-button-down ! --- Watch page: no next video --- www.youtube.com###related www.youtube.com##ytd-watch-next-secondary-results-renderer www.youtube.com,m.youtube.com##.ytp-endscreen-content www.youtube.com,m.youtube.com##.videowall-endscreen www.youtube.com,m.youtube.com##.ytp-ce-element www.youtube.com##.ytp-fullscreen-grid m.youtube.com##ytm-item-section-renderer[section-identifier="related-items"] ! --- Search: injected recommendation shelves --- www.youtube.com##ytd-search ytd-shelf-renderer www.youtube.com##ytd-search ytd-horizontal-card-list-renderer ! YouTube: redirects to the intentional view www.youtube.com,m.youtube.com#%#(function(){function g(a,t){for(const f of t){const p=new RegExp(f.from).exec(a);if(!p)continue;const i=f.to.replace(/\$(\d)/g,(m,c)=>p[Number(c)]??"");return i===a?null:i}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 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,s=e===o.body||e===o.documentElement?o.elementFromPoint(t.innerWidth/2,t.innerHeight/2):e;for(;s;s=s.parentElement){const u=t.getComputedStyle(s);if(n&&/^(y|block) (mandatory|proximity)$/.test(u.scrollSnapType)&&s.scrollHeight>s.clientHeight)return s;!n&&u.scrollSnapAlign!=="none"&&(s.matches("video")||s.querySelector("video"))&&(n=!0)}return null},i={capture:!0,passive:!1},m=e=>{const o=e.target,n=o instanceof t.Element?o:t.document.body;if(!n)return;const s=p(n),u=s?.querySelector("video")??(s&&s!==t.document.body?s.querySelector("img"):null);if(!s||!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}!s.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)},i),t.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey&&!e.altKey&&["ArrowUp","ArrowDown","PageUp","PageDown"].includes(e.key)&&m(e)},i);let c;t.addEventListener("touchstart",e=>{const o=e.touches[0];c=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(c&&o&&e.touches.length<=1){const n=Math.abs(o.clientY-c.y);n>8&&n>Math.abs(o.clientX-c.x)&&m(e)}e.type==="touchend"&&(c=void 0)};t.addEventListener("touchmove",h,i),t.addEventListener("touchend",h,i),t.addEventListener("touchcancel",()=>{c=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,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 p=0,i=!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},c=()=>{i=!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())}},h=()=>{i||(i=!0,t.setTimeout(c,50))};for(const r of["pushState","replaceState"]){const d=t.history[r];t.history[r]=function(...e){const o=d.apply(this,e);return c(),o}}t.addEventListener("popstate",c),a.select.length>0&&new t.MutationObserver(h).observe(f,{childList:!0,subtree:!0}),t.setInterval(c,1e3),c()}var y={"www.youtube.com":{redirects:[{from:"^/(\\?.*)?$",to:"/feed/subscriptions"},{from:"^/shorts/([A-Za-z0-9_-]+)/?\\?(?:[^&]*&)*lc=([A-Za-z0-9_.-]+)(?:&|$)",to:"/watch?v=$1&lc=$2"},{from:"^/shorts/([A-Za-z0-9_-]+)",to:"/watch?v=$1"},{from:"^/feed/(explore|trending)\\b",to:"/feed/subscriptions"},{from:"^/gaming\\b",to:"/feed/subscriptions"}],select:[]},"m.youtube.com":{redirects:[{from:"^/(\\?.*)?$",to:"/feed/subscriptions"},{from:"^/shorts/([A-Za-z0-9_-]+)/?\\?(?:[^&]*&)*lc=([A-Za-z0-9_.-]+)(?:&|$)",to:"/watch?v=$1&lc=$2"},{from:"^/shorts/([A-Za-z0-9_-]+)",to:"/watch?v=$1"},{from:"^/feed/(explore|trending)\\b",to:"/feed/subscriptions"},{from:"^/gaming\\b",to:"/feed/subscriptions"}],select:[]}}[location.hostname];y&&b(y,window)})();