! Title: Intentional: TikTok (AdGuard) ! Description: Removes TikTok'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 ! ===== TikTok ===== ! TikTok: see site.yaml for the policy and tests.yaml for what each rule must do. ! --- For You and Explore feeds (both redirect to Following) --- ! TikTok names each page's root `main-content-`, before and after in-app navigation. www.tiktok.com###main-content-homepage_hot www.tiktok.com###main-content-explore_page ||tiktok.com/api/recommend/item_list$xmlhttprequest,~third-party ||tiktok.com/api/prefetch/recommend/item_list$xmlhttprequest,~third-party ||tiktok.com/api/explore/item_list$xmlhttprequest,~third-party ||tiktok.com/api/prefetch/explore/item_list$xmlhttprequest,~third-party ! --- Side navigation: entries that only lead to algorithmic feeds --- www.tiktok.com##a[data-e2e="nav-foryou"] www.tiktok.com##a[data-e2e="nav-explore"] www.tiktok.com##a[data-e2e="nav-live"] www.tiktok.com##a[data-e2e="nav-short-drama"] ! --- A video opened by URL: the video and its comments, no queue of next videos --- ! The related list feeds the videos stacked under the opened one; the opened video is server-rendered. ||tiktok.com/api/related/item_list$xmlhttprequest,~third-party ! The mobile sharing page renders its recommendations outside the desktop detail column. www.tiktok.com##.layout-box:has(#video-card-normal) [data-e2e="recommend-list"] www.tiktok.com##.layout-box:has(#video-card-normal) [data-e2e="recommend-list-tab"] www.tiktok.com##:is(#main-content-video_detail, #main-content-homepage_follow) [data-e2e="recommend-list-item-container"]:not([data-scroll-index="0"]):is([data-scroll-index], [data-e2e="recommend-list-item-container"] ~ *) www.tiktok.com##:is(#main-content-video_detail, #main-content-homepage_follow) [data-e2e="feed-navigation-prev"] www.tiktok.com##:is(#main-content-video_detail, #main-content-homepage_follow) [data-e2e="feed-navigation-next"] www.tiktok.com#?##main-content-video_detail [data-testid="tux-web-tab-bar-container"]:contains(/^\s*You may like\s*$/) ! --- Suggested accounts (Following page, profiles) --- www.tiktok.com###main-content-homepage_follow [data-e2e="recommend-card"] www.tiktok.com##[data-testid="tux-web-button-container"]:has(> [data-e2e="show-suggested-accounts"]) www.tiktok.com##[data-e2e="user-page"] div:has(> div > div > [aria-label="View All"]) ! --- LIVE: the For You LIVE feed and its entry points (the hub redirects to Following LIVE) --- www.tiktok.com##a[data-e2e="nav-discover-live"] www.tiktok.com##a[data-e2e="discover-nav-category-tab"][href="/live"] [$path=/^\\/live\\/?(\\?|$)/]www.tiktok.com##[data-e2e="discover-list-live-card"] [$path=/^\\/live\\/?(\\?|$)/]www.tiktok.com##[data-e2e="discover_category-list-live-card"] ! --- Short dramas hub (redirects to Following) --- www.tiktok.com##[data-e2e="short-drama-library-page"] ! TikTok: redirects to the intentional view www.tiktok.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 s=e.closest(u)||Array.from(o.querySelectorAll(u)).find(b=>b.getClientRects().length>0);if(s)return s}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},i={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 s=n;for(;s&&s!==t.document.body;s=s.parentElement)if(s.scrollHeight>s.clientHeight&&/^(auto|scroll)$/.test(t.getComputedStyle(s).overflowY)&&!s.contains(u)){s instanceof t.HTMLElement&&t.getComputedStyle(s).overscrollBehaviorY==="auto"&&(s.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)},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 E(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.tiktok.com":{singleVideo:{path:"^/(?:@[^/]+/(?:video|photo)/[0-9]+|following)/?$",viewer:"#column-list-container, .layout-box #video-card-normal"},redirects:[{from:"^/(foryou/?)?(\\?.*)?$",to:"/following"},{from:"^/explore/?(\\?.*)?$",to:"/following"},{from:"^/live/?(\\?.*)?$",to:"/live/following"},{from:"^/shortdrama/?(\\?.*)?$",to:"/following"}],select:[]}}[location.hostname];y&&E(y,window)})();