1 line
2.7 KiB
JavaScript
1 line
2.7 KiB
JavaScript
![]() |
(()=>{var o,u,f=new Set,b=document.createElement("link").relList.supports("prefetch"),y="instantAllowQueryString"in document.body.dataset,E="instantAllowExternalLinks"in document.body.dataset,L="instantWhitelist"in document.body.dataset,m="instantMousedownShortcut"in document.body.dataset,h=1111,p=65,w=!1,v=!1,c=!1,g=null;navigator.userAgentData&&navigator.userAgentData.brands.forEach(({brand:t,version:e})=>{t=="Chromium"&&(g=parseInt(e))});if("instantIntensity"in document.body.dataset){let t=document.body.dataset.instantIntensity;if(t.startsWith("mousedown"))w=!0,t=="mousedown-only"&&(v=!0);else if(t.startsWith("viewport"))navigator.connection&&(navigator.connection.saveData||navigator.connection.effectiveType&&navigator.connection.effectiveType.includes("2g"))||(t=="viewport"?document.documentElement.clientWidth*document.documentElement.clientHeight<45e4&&(c=!0):t=="viewport-all"&&(c=!0));else{let e=parseInt(t);isNaN(e)||(p=e)}}if(b){let t={capture:!0,passive:!0};if(v||document.addEventListener("touchstart",I,t),w?m||document.addEventListener("mousedown",O,t):document.addEventListener("mouseover",T,t),m&&document.addEventListener("mousedown",A,t),c){let e=window.requestIdleCallback;e||(e=n=>{n()}),e(function(){let i=new IntersectionObserver(s=>{s.forEach(l=>{if(l.isIntersecting){let d=l.target;i.unobserve(d),a(d.href)}})});document.querySelectorAll("a").forEach(s=>{r(s)&&i.observe(s)})},{timeout:1500})}}function I(t){u=performance.now();let e=t.target.closest("a");r(e)&&a(e.href,"high")}function T(t){if(performance.now()-u<h||!("closest"in t.target))return;let e=t.target.closest("a");r(e)&&(e.addEventListener("mouseout",k,{passive:!0}),o=setTimeout(()=>{a(e.href,"high"),o=void 0},p))}function O(t){let e=t.target.closest("a");r(e)&&a(e.href,"high")}function k(t){t.relatedTarget&&t.target.closest("a")==t.relatedTarget.closest("a")||o&&(clearTimeout(o),o=void 0)}function A(t){if(performance.now()-u<h)return;let e=t.target.closest("a");if(t.which>1||t.metaKey||t.ctrlKey||!e)return;e.addEventListener("click",function(i){i.detail!=1337&&i.preventDefault()},{capture:!0,passive:!1,once:!0});let n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});e.dispatchEvent(n)}function r(t){if(!(!t||!t.href)&&!(L&&!("instant"in t.dataset))&&!(t.origin!=location.origin&&(!(E||"instant"in t.dataset)||!g))&&["http:","https:"].includes(t.protocol)&&!(t.protocol=="http:"&&location.protocol=="https:")&&!(!y&&t.search&&!("instant"in t.dataset))&&!(t.hash&&t.pathname+t.search==location.pathname+location.search)&&!("noInstant"in t.dataset))return!0}function a(t,e="auto"){if(f.has(t))return;let n=document.createElement("link");n.rel="prefetch",n.href=t,n.fetchPriority=e,n.as="document",document.head.appendChild(n),f.add(t)}})();
|